DESIGN SYSTEMS & CODE

CSS to Tailwind Utility Converter

Paste raw CSS — including shorthand, pseudo-classes, and media queries — and get idiomatic Tailwind utility classes back, instantly and entirely in your browser.

Shorthand Expansion (padding, border-radius, border)Pseudo-Class Variants (hover, focus, disabled)Media Query BreakpointsArbitrary Value & Property Fallback

Paste CSS

Load an example

On: 16px becomes p-4. Off: always outputs exact arbitrary values like p-[16px].

17 declarations converted
14 scale matches
3 arbitrary values
0 arbitrary properties
.btn
inline-flex items-center justify-center gap-2 py-3 px-6 bg-[#FF5B04] text-[#ffffff] text-sm font-semibold rounded-lg border-none cursor-pointer transition-colors duration-200
display: inline-flex
inline-flexScale Match
align-items: center
items-centerScale Match
justify-content: center
justify-centerScale Match
gap: 8px
gap-2Scale Match
padding: 12px 24px
py-3 px-6Scale Match
background-color: #FF5B04
bg-[#FF5B04]Arbitrary Value
color: #ffffff
text-[#ffffff]Arbitrary Value
font-size: 14px
text-smScale Match
font-weight: 600
font-semiboldScale Match
border-radius: 8px
rounded-lgScale Match
border: none
border-noneScale Match
cursor: pointer
cursor-pointerScale Match
transition-property: background-color
transition-colorsScale Match
transition-duration: 200ms
duration-200Scale Match
.btn:hover
hover:bg-[#E54F00]
background-color: #E54F00
bg-[#E54F00]Arbitrary Value
.btn:disabled
disabled:opacity-50 disabled:cursor-not-allowed
opacity: 0.5
opacity-50Scale Match
cursor: not-allowed
cursor-not-allowedScale Match

Full Export

/* .btn */
inline-flex items-center justify-center gap-2 py-3 px-6 bg-[#FF5B04] text-[#ffffff] text-sm font-semibold rounded-lg border-none cursor-pointer transition-colors duration-200

/* .btn:hover */
hover:bg-[#E54F00]

/* .btn:disabled */
disabled:opacity-50 disabled:cursor-not-allowed
Frontend Migration Guide

How This Converter Works

Every CSS declaration you paste is resolved through three tiers, tried in order, so nothing is ever silently dropped — only shortened when a clean match exists.

Tier 1 · Scale Match

Named Utility Classes

If a value lines up with Tailwind's default design scale — 16px padding, 8px radius, 700 font weight — it becomes a short, semantic class like p-4, rounded-lg, font-bold.

Tier 2 · Arbitrary Value

Custom Values, Known Utility

A value like 13px padding doesn't exist on Tailwind's scale, but padding itself is a known utility — so it converts to p-[13px] using Tailwind's official bracket syntax instead of rounding to the nearest step and silently changing your design.

Tier 3 · Arbitrary Property

Anything Tailwind Doesn't Name

Properties with no Tailwind utility at all — mask-type, vendor prefixes, exotic CSS — fall back to Tailwind's arbitrary property syntax: [mask-type:luminance]. It's valid, real Tailwind — just less common knowledge.

What This Converter Understands

Shorthand expansion

padding, margin, border-radius, and border shorthand are decomposed into their per-side/per-corner Tailwind classes — or collapsed to px-/py- when both axes match.

Border-radius corner order

CSS border-radius reads top-left → top-right → bottom-right → bottom-left, not the top/right/bottom/left order padding and margin use. This converter applies the correct order automatically.

Pseudo-class variants

:hover, :focus, :active, :disabled, :first-child, ::before, ::after and more map to Tailwind's hover:, focus:, disabled: variant prefixes.

Media query breakpoints

@media (min-width: 768px) maps to Tailwind's sm:/md:/lg:/xl:/2xl: prefixes using the same default breakpoint scale.

Percentages as fractions

width: 50% becomes w-1/2, width: 33.333% becomes w-1/3 — matching Tailwind's built-in fraction scale instead of falling back to arbitrary values.

!important and negative values

color: red !important becomes !text-[red]; margin-top: -8px becomes -mt-2, following Tailwind's own negative-value convention.

Known Limitations

This runs entirely in your browser with a lightweight parser, not a full CSS AST — it's built for component-level CSS (buttons, cards, nav bars), not entire stylesheets. A few things it intentionally doesn't attempt:

  • Native CSS nesting (& selectors) — flatten your rules first.
  • Gradients, background images, and multi-function transform values are preserved exactly via arbitrary property/value syntax rather than decomposed into multiple utilities.
  • Colors always convert to arbitrary values (bg-[#ff5b04]) rather than guessing the nearest built-in Tailwind shade — guessing can silently shift your brand color.
  • Complex selectors like :nth-child(2n+1) aren't mapped to a variant; they're flagged so you can add it manually.

Step-by-Step: How to Use This Converter

01

Paste your CSS

Paste one or more rules, including pseudo-classes and @media blocks — or just a bare declaration list with no selector at all.

02

Choose your scale preference

Leave 'Prefer Tailwind's Default Scale' on for the shortest, most idiomatic output. Turn it off when you need pixel-perfect fidelity to the original design.

03

Read the per-rule breakdown

Each original selector gets its own card showing the exact Tailwind classes, plus a property-by-property table so you can sanity-check every conversion.

04

Copy classes into your component

Use the per-rule 'Copy classes' button for a single element, or 'Copy All' to grab every converted rule at once, commented by original selector.

Frequently Asked Questions

What is Tailwind's arbitrary value syntax?

Square-bracket syntax like p-[13px] or bg-[#ff5b04] lets you use a one-off CSS value with a Tailwind utility, without adding it to your config. It's an official, fully-supported part of Tailwind CSS v3 and v4.

What's the difference between arbitrary values and arbitrary properties?

Arbitrary values (p-[13px]) customize the value for a utility Tailwind already knows about. Arbitrary properties ([mask-type:luminance]) let you use a raw CSS property Tailwind has no utility for at all — both compile to real, valid CSS.

Why do colors always come out as bg-[#hex] instead of bg-orange-500?

Matching a hex value to the 'nearest' built-in Tailwind color is a guess, and a wrong guess silently changes your brand color. Arbitrary values preserve your exact color every time — swap in a design token yourself if you have one.

Can I paste an entire stylesheet?

You can, but this tool is tuned for component-level CSS — a button, a card, a nav bar. Very large stylesheets with deep nesting or hundreds of rules will still parse, but the output is easier to review in smaller chunks.

Does this handle Sass or LESS syntax?

No — paste compiled, plain CSS. Nesting (&), variables ($var), and mixins aren't understood by the parser.

UI Pirate Ecosystem

Suggested Tools for Your Stack

Explore related utilities in this workflow or discover cross-category tools.

View All Tools →