CSS to Tailwind Converter, Both Directions

Paste ordinary CSS rules and this converter returns a Tailwind v4 class list for each selector, using named classes where the default theme has an exact match and arbitrary values such as w-[37px] where it does not. Flip the direction to turn a class list back into CSS. Selectors and rules that cannot become classes are listed, never silently dropped.

How common declarations convert (Tailwind v4 default theme)
CSSTailwindWhy
padding: 16px 24pxpy-4 px-6Spacing steps are 0.25rem, so 16px is step 4
width: 37pxw-[37px]Not a whole or half step, so an arbitrary value
border-radius: 12pxrounded-xlrounded-xl is 0.75rem in the default theme
justify-content: space-betweenjustify-betweenDirect keyword match
box-shadow: 0 1px 2px #0001[box-shadow:0_1px_2px_#0001]Written as an arbitrary property; spaces become underscores
@media (min-width: 768px)md: prefixmd starts at 48rem, which is 768px

Updated

Moving a stylesheet into Tailwind by hand means looking up dozens of class names and doing pixel to rem arithmetic in your head. This converter does the lookup and the maths, shows which classes are arbitrary values you might want to round to the scale, and tells you plainly which rules have to stay in a CSS file.

Converter

Paste CSS rules or a Tailwind class list. Arbitrary values are highlighted and anything that cannot be converted is listed below the result.

A worked example

CSS in

A card rule with a hover state and a tablet breakpoint.

.card {
  display: flex;
  padding: 16px 24px;
  gap: 1rem;
  border: 1px solid #e5e5e5;
  border-radius: 12px;
}
.card:hover { background-color: #f8fafc; }
@media (min-width: 768px) {
  .card { padding: 32px; }
}

Tailwind out

Each declaration becomes a class; the hover and breakpoint rules become prefixed classes on the same element.

<div class="flex py-4 px-6 gap-4 border border-[#e5e5e5] rounded-xl hover:bg-[#f8fafc] md:p-8">...</div>

Converting a stylesheet without making a mess

Start with the components you touch most and convert one selector at a time. Paste the converted classes into the markup, delete the old rule, and check the page before moving on.

Leave complex selectors, animations and third-party overrides in CSS. Tailwind works alongside normal stylesheets, and forcing everything into classes usually makes markup harder to read.

Reading the result

Named classes are values that already exist on the default scale. Highlighted classes are arbitrary values: correct, but outside your design system, so they are the first place to look for near misses.

Shorthands are expanded per side. padding: 8px 16px becomes py-2 px-4, and a four-value margin becomes mt, mr, mb and ml classes.

How it works

  1. Choose CSS to Tailwind or Tailwind to CSS.
  2. Paste your rules or your class list. The result updates as you type.
  3. For CSS input, each simple selector gets its own class list. :hover, :focus and similar become variants, and min-width media queries become breakpoint prefixes.
  4. Read the notes under the result: arbitrary values are highlighted and anything left out is listed with the reason.

Tips

Frequently asked questions

Which Tailwind version does it target?

Tailwind v4 with the default theme. Spacing is calculated from the 0.25rem --spacing value, radius names follow the v4 scale (rounded-xs is 2px, rounded-sm 4px, rounded-md 6px and so on), and breakpoints use the v4 rem values.

Why do I get arbitrary values instead of named classes?

A named class is used only when it gives exactly the same value. Colours always become arbitrary values because a hex code rarely matches a palette shade exactly, and font sizes stay arbitrary because named text sizes also set a line height.

What does it not convert?

Selectors with descendants, siblings or attributes, media queries that are not a single min-width, keyframes and other at-rules, and custom properties. They appear in the not converted list so you can move them to your CSS file.

How accurate is Tailwind to CSS?

Classes in the converter's table, arbitrary values and arbitrary properties come back exactly, with spacing shown as rem values that assume the default --spacing. Theme colour names such as bg-blue-500 and preset shadows are not in the table and are listed as skipped rather than guessed.

Is there a Tailwind class for every CSS property?

No, but the arbitrary property syntax [property:value] covers anything Tailwind does not have a utility for, such as [mask-type:luminance]. This converter uses it for any property it does not recognise.

Related: Tailwind cheat sheet, PX to REM converter, Tailwind vs Bootstrap, Tailwind colour palette generator, CSS formatter.

Start for free or see all free tools. We.Inc is free to start, with no card needed. AI building is on paid plans from $20 a month.

More in Free Tools

We.Inc is an AI-powered website builder you can resell under your own brand. Launch a branded client dashboard, bill on Stripe Connect, and deliver AI-generated websites in minutes. White-label plans start at $99 a month for 25 client sites, with a 7-day free trial and no per-site fees.

Product

Who It's For

Features

Resources

Company

View Sitemap