CSS to Tailwind Converter
Turn CSS declarations into Tailwind classes: exact matches first, arbitrary values when a scale entry does not exist, and a comment for anything unmapped.
What the CSS to Tailwind Converter does
Exact matches come from a small, stated table: display, position, justify-content, align-items, text-align, font-weight and flex-direction. Everything else that has a utility prefix becomes an arbitrary value — p-[16px], text-[red] — which is valid Tailwind and keeps the exact CSS value.
With more than one rule in the input, each block is preceded by a # selector comment so the classes stay attributable.
This is a translator, not a design system. There is no palette lookup, so color: red becomes text-[red] rather than text-red-500; a property outside the table (a shorthand, a custom property, a vendor prefix) is reported as unsupported rather than guessed.
How to use it
Paste the declarations into the CSS declarations box, or press Run with the example already there.
Read the Tailwind classes below: one class per line, with # selector lines when the input has more than one rule.
Check an unsupported line in the Tailwind classes — it names a property this page has no class for, which you translate by hand.
Worked example
Input:
.x { display: flex; justify-content: center; gap: 8px; padding: 16px; color: red; }
Output:
flex
justify-center
gap-[8px]
p-[16px]
text-[red]
Why it runs in your browser
The result is produced on this page with JavaScript, so it works offline after the page loads and nothing you enter is sent anywhere.
A class list for a rule you already wrote: `display: flex` becomes `flex`, `justify-content: center` becomes `justify-center`, and a value with no scale entry becomes an arbitrary class like `gap-[8px]`.
A property with no Tailwind spelling is reported as a comment naming it, so the gap in the output is visible rather than silently dropped.
What it does, and what it does not
Exact matches come from a small, stated table: display, position, justify-content, align-items, text-align, font-weight and flex-direction. Everything else that has a utility prefix becomes an arbitrary value — `p-[16px]`, `text-[red]` — which is valid Tailwind and keeps the exact CSS value.
With more than one rule in the input, each block is preceded by a `# selector` comment so the classes stay attributable.
This is a translator, not a design system. There is no palette lookup, so `color: red` becomes `text-[red]` rather than `text-red-500`; a property outside the table (a shorthand, a custom property, a vendor prefix) is reported as unsupported rather than guessed.
How to use CSS to Tailwind Converter
Paste the declarations into the CSS declarations box, or press Run with the example already there.
Read the Tailwind classes below: one class per line, with `# selector` lines when the input has more than one rule.
Check an unsupported line in the Tailwind classes — it names a property this page has no class for, which you translate by hand.
What to Expect
Best for
- Porting a small rule into a utility class list
- Checking which value becomes an arbitrary class
Not ideal for
- A whole stylesheet with shorthand properties
- Mapping to a custom palette
What this tool keeps
- The exact CSS value inside an arbitrary class
- One class per declaration
What may need cleanup
- A shorthand like `padding: 8px 16px` needs splitting first
- A palette colour is arbitrary, not a named shade
Common errors
- The page refuses it: "color red" has no colon
Example use cases
- Converting a component rule before deleting the CSS
- Reviewing which properties have no utility
Sample input
CSS declarations: .x { display: flex; justify-content: center; gap: 8px; padding: 16px; color: red; }
Sample output
Tailwind classes: flex …
Who this is for
- Developers migrating CSS to Tailwind
- Anyone checking a utility spelling
Frequently asked questions
Why is `gap: 8px` an arbitrary value?
Arbitrary values are exact and need no scale table. A named class would require assuming your Tailwind theme's spacing scale, which the page cannot see.
What does an unsupported comment mean?
The property has no entry in the mapper's table. It is printed as /* unsupported: property */ so the translation gap is visible instead of the declaration vanishing.
Does it handle `@media`?
No. A class list is per selector, and a media query changes when the classes apply. The page refuses an at-rule by name rather than dropping the condition.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.