Account

What new tool do you want?

Developer Tools

CSS to Tailwind Converter

Convert plain CSS declarations or rules into Tailwind CSS utility classes — spacing, flexbox, grid, typography, colors, borders and more, with arbitrary values where needed.

How to use

  1. 1Paste CSS — a whole rule (.btn { … }) or just declarations.
  2. 2Copy the Tailwind classes for each selector.

How it's calculated

Values on Tailwind's default scale map to named classes (16px → 4, 1.5rem → 6); anything else becomes an arbitrary value like w-[37px] or [prop:value].

Frequently asked questions

Does it handle hover and media queries?

Not automatically — add variants yourself, e.g. hover:bg-blue-600 or md:flex, around the converted classes.

Why do I see brackets like text-[#1e40af]?

Values that aren't on Tailwind's default scale become arbitrary values. Swap in your theme colors (e.g. text-blue-800) if they match.

Which Tailwind version is this for?

Class names match Tailwind v3 and v4 defaults (spacing unit 0.25rem).

Worked example: CSS to Tailwind Converter

Paste .btn { display: inline-flex; align-items: center; padding: 8px 16px; border-radius: 8px; font-weight: 600; background-color: #2563eb; color: white; } and you get .btn → inline-flex items-center py-2 px-4 rounded-lg font-semibold bg-[#2563eb] text-white. Notice padding: 8px 16px (vertical 8px, horizontal 16px) correctly splits into py-2 px-4 rather than a single padding class, because Tailwind has no single utility for asymmetric padding — and #2563eb falls back to the arbitrary-value syntax bg-[#2563eb] rather than a named color, because the converter has no way to know that's actually Tailwind's own blue-600 unless you tell it.

Why so many colors end up as bg-[#2563eb] instead of bg-blue-600

Tailwind's color palette (blue-600, emerald-500, and so on) isn't a fixed, universal mapping from hex codes — it's generated from an internal color scale that most projects can also customize, so there's no reliable way to reverse-engineer "this hex is definitely blue-600" without assuming every project uses Tailwind's untouched defaults. The converter only maps values it can be certain about (white, black, transparent) to named classes and falls back to arbitrary-value syntax for everything else — which still works perfectly as valid Tailwind, it just doesn't get you the shorter, themeable class name. Swapping in your actual theme color name afterward is a manual step worth doing for anything that'll be reused.

What it deliberately leaves out

The converter only translates static declarations — it has no concept of :hover, :focus, or @media breakpoints, because those require you to decide the variant prefix (hover:, md:, dark:) based on context the plain CSS declaration doesn't carry. Paste a :hover block and the selector shown won't include the pseudo-class; you'd wrap the converted utility classes with hover: yourself. That's a deliberate scope boundary, not a bug — automatically guessing which breakpoint or state a given rule was meant for would be guesswork the tool can't reliably get right.

Comments are stripped first, and a rule with no classes is an error

Comments are removed before anything is converted. If nothing is left, the result is empty. A block with braces keeps its selector on its own line, with the class names underneath. A declaration list with no braces is treated as one rule and only the classes come back. A declaration without a colon is skipped. If no declaration converts, I get "No CSS declarations found" and a sample of the shape it wants. I see that when I paste a selector by itself, or a comment, and expect classes. I add the braces and try again.

Related tools

More: Developer Tools