CSS to Tailwind

Convert CSS declarations into Tailwind utility classes.

Unknown properties become Tailwind arbitrary values, e.g. [prop:value].

CSS to Tailwind converts plain CSS declarations into Tailwind utility classes. It maps the common properties — flexbox, spacing, typography, colors, borders, positioning — to their Tailwind equivalents, converting pixel values onto Tailwind's spacing scale. Anything it doesn't have a named utility for becomes a valid Tailwind arbitrary value, so the output always compiles.

  • Maps flexbox, spacing, sizing, typography and colors
  • Converts px values onto the Tailwind spacing scale
  • Arbitrary-value fallback for anything uncommon
  • 100% private — nothing is uploaded

How the Mapping Works

Well-known declarations map to their canonical utilities — display: flex becomes flex, padding: 16px becomes p-4(Tailwind's scale is 4px per unit), and font-weight: 600 becomes font-semibold. For properties without a preset, it uses Tailwind's arbitrary-value syntax like [grid-template-columns:1fr_2fr], which is valid Tailwind. Treat the result as a strong starting point you can refine with your design tokens.

What Tailwind's Spacing Scale Actually Is

Tailwind doesn't use raw pixels for spacing utilities — it uses a numbered scale where each step is 0.25rem (4px at the default browser font size). That's why padding: 16px becomes p-4 rather than something like p-16: the number in the class name is the scale step, not the pixel value.

CSS valueScale stepTailwind class
4px1p-1
8px2p-2
16px4p-4
24px6p-6
32px8p-8
13px (off-scale)p-[13px] (arbitrary value)

How to Use It

  1. 1Paste a CSS rule or a block of standalone declarations into the input.
  2. 2Click Convert — each declaration maps to its Tailwind utility, or to an arbitrary-value class like [prop:value] if there's no named utility.
  3. 3Copy the resulting class list and paste it into your JSX/HTML className.
  4. 4Review colors and any arbitrary values against your project's design tokens — swap an exact hex like bg-[#1e293b] for a theme color like bg-slate-800 where it's a genuine match.

Common Uses

  • Migrating to TailwindConvert existing stylesheet rules into utility classes when adopting Tailwind in a project.
  • Design-tool exportsTurn CSS copied from a design tool or dev tools inspector into Tailwind classes.
  • Learning TailwindSee the Tailwind equivalent of CSS you already know to build up your mental mapping.
  • Quick prototypingPaste a snippet and get classes to drop onto an element without hunting the docs.
  • Code reviewSanity-check that a teammate's raw CSS in a pull request has a clean Tailwind equivalent before merging.

When Arbitrary Values Are the Right Answer

Tailwind's arbitrary-value syntax — square brackets around a property or value, like [mask-type:luminance] or top-[117px]— isn't a fallback to be avoided; it's an intentional escape hatch for the cases a fixed design-system scale can't predict: a pixel-perfect value from a design handoff, a CSS property Tailwind doesn't ship a utility for, or a one-off value that will never repeat elsewhere. Reach for a named utility when the value should follow your design system, and keep the arbitrary form when precision matters more than consistency.

Frequently Asked Questions

It maps the most common properties to named Tailwind utilities and converts everything else to Tailwind's arbitrary-value syntax, so the output is always valid even for uncommon declarations.

Tailwind's spacing scale uses 4px per unit, so 16px becomes 4, 8px becomes 2, and so on. Values that don't land on the scale are emitted as arbitrary values like p-[13px].

Colors are emitted as arbitrary values such as bg-[#1e293b] to stay exact. Swap them for your theme's named colors (like bg-slate-800) where they match.

No. The conversion runs entirely in your browser. Nothing is sent to a server.

Yes — paste a rule like .card { padding: 16px; } and the tool extracts the declarations inside the braces and converts them, ignoring the selector itself since Tailwind classes apply directly to elements.

Utility classes trade brevity for locality — each property becomes its own class rather than being grouped under one rule. This is expected with utility-first CSS and is what enables Tailwind's build to purge unused styles.

Related Tools