CSS to Tailwind Converter

Turn CSS rules into Tailwind utility classes, with colors matched to the Tailwind palette, hover and breakpoint variants, and arbitrary values for the rest.

Processed on your device. Files are not uploaded

How to convert CSS to Tailwind

  1. Paste your CSS

    Paste or type your CSS into the box, or press Try an example.

  2. Read the classes

    Each selector gets its list of classes.

  3. Copy into your markup

    Paste the classes into the class or className attribute.

Worked example

This is what CSS to Tailwind Converter gives for its own sample values. Open the tool above and change anything to try your own.

CSS rules or declarations

.card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background-color: #ffffff;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  font-size: 14px;
  font-weight: 600;
  color: #0f766e;
}
.card:hover { background-color: #f8fafc; }
...

.card

flex items-center gap-4 py-4 px-6 border border-slate-200 rounded-xl bg-white shadow-md text-sm font-semibold text-[#0f766e] hover:bg-slate-50 md:py-6 md:px-8

When to use CSS to Tailwind Converter

A project is moving to Tailwind and existing components need their CSS rewritten as utility classes.

You know the CSS you want and need to find the Tailwind class names for it.

Tips for a better CSS to Tailwind Converter result

Convert one component at a time and compare it on screen, since cascade and specificity work differently with utilities.

Look at the arbitrary values in square brackets afterwards; repeated ones are good candidates for your theme.

CSS to Tailwind Converter: limits and what to check

Rules that style child elements through a parent selector need the classes moved onto the children by hand.

Animations, keyframes and complex grid templates usually need a theme entry or custom CSS rather than one class.

About CSS to Tailwind Converter

Move existing CSS into Tailwind. Declarations map to utility classes, colors are matched to the nearest Tailwind color when it looks the same, pixel values map to the spacing scale, :hover and min-width media queries become variants, and anything without a utility becomes an arbitrary value so nothing is lost.

FAQs

What happens to colors not in Tailwind's palette?

They become arbitrary values such as text-[#1d4ed8], unless a palette color is so close the difference cannot be seen.

Are shorthand properties split?

padding and margin with two to four values become the matching x, y and side classes.

Does it handle complex selectors?

Classes are given per selector. Descendant and attribute selectors need to be applied to the right element by hand.

Related tools