Skip to main content

CSS ↔ Tailwind Converter

Convert CSS rules to Tailwind CSS v4 classes and Tailwind classes back to CSS.

CSS Input

0 of 1,048,576 bytes

Options

Fidelity: Best effort

Tailwind Classes Output

Paste CSS or load an example.

Runs locally in your browser. Targets Tailwind CSS v4 only; v3 compatibility is not offered.

How to use

  1. 1.Choose CSS → Tailwind or Tailwind → CSS, then paste your input or load an example.
  2. 2.Small inputs convert as you type; large inputs convert when you select Convert.
  3. 3.Check the report and the Diagnostics list for arbitrary values, complex selectors, overridden properties and unknown classes, and select a line to jump to it.
  4. 4.Swap moves the output into the input and switches the direction.

CSS ↔ Tailwind Converter

The CSS to Tailwind direction parses your stylesheet, groups declarations by selector and variant, expands shorthands such as padding, margin, inset, border and border-radius, and then maps every property in four stages: exact keyword utilities such as flex or items-center, Tailwind v4 theme scales such as p-4 for 1rem or rounded-lg for 0.5rem, arbitrary values such as w-[37px], and arbitrary properties such as [mask-type:luminance]. Media queries that match a v4 breakpoint exactly become sm, md, lg, xl or 2xl; other widths become min-[37rem]. The Tailwind to CSS direction resolves each class from the same mapping table and writes generated equivalent CSS for one selector, with variants grouped into nested selectors and media queries. It is generated CSS for the default v4 theme, not a recovery of an original stylesheet.

How values are matched

Spacing utilities use the v4 scale of 0.25rem steps, so 1rem becomes 4 and 0.375rem becomes 1.5. With Match px to theme on, pixel values are converted with a 16px root, so 16px also becomes 4. Font sizes match the v4 text scale, and a matching line height is folded into the text size utility. Colours become theme utilities only for black, white, transparent, currentColor and Tailwind palette variables such as var(--color-blue-600); other colours stay arbitrary values such as bg-[#1e293b] instead of a guessed palette name. Important declarations use the v4 suffix, as in flex!, and negative values use a leading minus, as in -mt-4.

Limits

Only Tailwind CSS v4 is targeted; v3 class names and configuration files are not read. Selectors with descendants, children, siblings or attributes are converted for their last element and flagged. Keyframes, font faces and imports are skipped. Input is limited to 1 MiB and 256 nesting levels.

Privacy

Conversion runs locally in your browser. Input and output are never uploaded or stored; only your option choices are remembered on this device.

Frequently asked questions
Which Tailwind version does the converter target?
Tailwind CSS v4 with its default theme: 0.25rem spacing steps, v4 names such as shadow-xs and rounded-xs, a 1px ring, outline-hidden, the important suffix as in flex! and breakpoints at 40, 48, 64, 80 and 96rem. A v3 compatibility mode is not offered.
Why do some colours become arbitrary values?
Only black, white, transparent, currentColor and Tailwind palette variables such as var(--color-blue-600) map to palette utilities. Other colours stay exact arbitrary values such as bg-[#1e293b] instead of a guessed nearest palette name.
Is the CSS from Tailwind classes the original stylesheet?
No. It is generated equivalent CSS for one selector and the default v4 theme. Unknown classes from plugins or custom configuration are listed as warnings.

CodingTool is officially live on