CSS to Tailwind converter
Convert CSS to Tailwind classes
Paste CSS and get the Tailwind utilities for each rule, with arbitrary values where no class matches exactly.
CSS
Tailwind classes
- Free, no sign-up
- Runs in your browser
- Your code never leaves your device
How to use it
How to use the CSS to Tailwind tool
Free, with no sign-up. Everything happens in your browser.
- 01
Paste your CSS
Whole stylesheets with media queries and :hover rules, a single rule, or just the declarations from DevTools' Styles panel.
- 02
Read the classes
Each selector gets one line of Tailwind classes. Hover, focus and responsive rules are merged in as hover:, focus: and md: variants.
- 03
Copy them into your markup
Copy one selector's classes into its class attribute, or switch to @apply CSS to keep your class names and move the styles to Tailwind.
Guide
How CSS maps to Tailwind classes
Most CSS declarations have a matching Tailwind utility. The converter picks the class from Tailwind's default theme when your value is on it, and writes an arbitrary value in square brackets when it isn't, so nothing is lost.
Values on the theme scale
Tailwind's spacing scale counts in quarters of a rem: 4px is 1, 16px is 4 and 24px is 6. So padding: 16px becomes p-4 and margin-top: 24px becomes mt-6. Font sizes, font weights, line heights, border radii and max widths have named steps too, like text-xl, font-semibold and rounded-lg.
Shorthands are expanded and then written as compactly as possible: padding: 8px 16px becomes py-2 px-4, and margin: 0 auto becomes my-0 mx-auto.
.card {
padding: 24px 32px;
border-radius: 12px;
font-weight: 600;
}py-6 px-8 rounded-xl font-semiboldColors from the palette
Hex and rgb() colors that are on Tailwind's default palette get their name: #3b82f6 is blue-500 and #e5e7eb is gray-200. Transparency becomes the opacity modifier, so rgba(0, 0, 0, 0.5) is black/50.
Brand colors that aren't on the palette are kept exactly, as bg-[#038770]. If you use one often, add it to your theme and swap the arbitrary value for its name.
Arbitrary values and properties
When a value isn't on the theme, the converter wraps it in square brackets: width: 13px becomes w-[13px]. Spaces inside the value turn into underscores, the way Tailwind expects, so a box-shadow becomes shadow-[0_1px_3px_rgba(0,0,0,0.1)].
For properties Tailwind has no utility for at all, like mask-image, it writes an arbitrary property such as [mask-image:linear-gradient(black,transparent)]. These still work in your markup and the notes list them.
width: 13px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
mask-image: linear-gradient(black, transparent);w-[13px]
shadow-[0_1px_3px_rgba(0,0,0,0.1)]
[mask-image:linear-gradient(black,transparent)]Hover, focus and media queries become variants
Tailwind puts states and breakpoints in front of the class instead of in separate rules. .button:hover { background: … } becomes hover:bg-…, ::before becomes before:, and li:nth-child(odd) becomes odd:.
Media queries at Tailwind's breakpoints become sm:, md:, lg:, xl: and 2xl:. Other widths use min-[900px]: or max-[600px]:, and prefers-color-scheme: dark becomes dark:. Everything is merged into the base selector's line, so you see all of an element's classes together.
.button:hover { background: #027a65; }
@media (min-width: 768px) {
.card { flex-direction: row; }
}hover:bg-[#027a65]
md:flex-rowClasses or @apply
Moving to Tailwind usually means putting the classes in your HTML or JSX and deleting the CSS rule. When that isn't practical, for example with markup you don't control, the @apply CSS output keeps your selectors and applies the utilities inside them.
Rules for descendant selectors like .card h2 are listed separately: their classes go on the h2 itself.
What it handles
Built for real-world code
The details that usually need fixing by hand, done for you.
Checked against real Tailwind
The converter only writes classes Tailwind 3 generates, and our tests compile its output with Tailwind to keep it that way.
Responsive and state rules merged
Media queries, :hover, :focus and pseudo-elements are folded into one class list per element as md:, hover: and before: variants.
Nothing silently dropped
Values off the theme become arbitrary values, unknown properties become arbitrary properties, and the notes say what was skipped and why.
Private by design
The conversion runs in your browser. Your CSS isn't uploaded, stored or logged anywhere.
Import Code
Converting a whole project?
Import your existing HTML, ask AI to rewrite it with Tailwind, and preview every version before you download the result.
Yes. It's free with no sign-up and no limits, and it runs entirely in your browser.
More free tools
Keep going
More converters for HTML, React and Tailwind.