Skip to content
TypeParser
All tools

CSS to Tailwind

Convert CSS declarations to Tailwind classes.

beats tailwind-converter.netlify.app edge: Arbitrary-value fallback + preset matching
CSS
paste CSS
Guide

About CSS to Tailwind

Convert CSS declarations to Tailwind utility classes. Maps common properties (padding, margin, color, flex, grid, font-size, border-radius) to preset Tailwind classes. Falls back to arbitrary values (<code>p-[7px]</code>) when no preset matches. Useful for migrating to Tailwind and for one-shot CSS-to-utility translation.

Migrate-to-Tailwind reality

Pure mechanical conversion gets you 80% there. The remaining 20% is rethinking — Tailwind rewards utilities over selectors, components over global styles. The output of this tool is a starting point, not a finished migration.

What translates well

  • Spacing (padding, margin)
  • Color (color, background-color, border-color)
  • Layout (display: flex, display: grid, flex-direction)
  • Typography (font-size, font-weight, line-height)
  • Border (radius, width, style)
  • Shadow

What translates poorly

  • Complex selectors (descendant, attribute, pseudo-class chains)
  • CSS animations with keyframes
  • Print stylesheets
  • Container queries (Tailwind v4 added support; v3 needs a plugin)

Common workflows

Convert a snippet for inline use. CSS in a docs example → Tailwind class string for a live demo.

Bootstrap a component migration. Paste the existing CSS, get utilities, refine to component conventions.

Inspect what Tailwind would emit. Useful for writing CSS that “feels Tailwind-ish” so a future migration is easier.

Extract from a design tool. Figma → CSS → Tailwind, faster than typing the utilities by hand.

Frequently asked questions

Tailwind v3 or v4?
Default v3 (most-deployed). Toggle v4 for the new @theme / OKLCH-default conventions.
How does preset matching work?
Each property has a known scale (0, 0.5, 1, 1.5, ..., 96 in Tailwind's spacing). Inputs that fit map to the preset (4px → p-1); inputs that don't get arbitrary values (7px → p-[7px]).
Custom theme support?
Default theme. For project-specific colors / spacing, edit the output by hand or extend the converter via the Custom theme JSON paste.
What about state selectors?
:hover becomes hover: prefix. :focus, :active, ::before similarly. Media queries map to md:, lg:, etc.
Will it nest correctly?
The converter outputs flat utility strings. Nested CSS (descendant selectors, child selectors) is not directly expressible in Tailwind — it surfaces as a comment for manual refactoring.
Migrate a whole stylesheet?
Possible but labor-intensive. The tool helps with each rule; structuring the migration (which selectors apply where) is manual.

Related tools

Last updated: 2025-01-15