CSS to Tailwind Converter
Paste CSS and get Tailwind classes for each selector — exact scale values where they exist, arbitrary values where they don’t, and every approximation flagged. Converts as you type, in your browser.
At a glance
- Outputs Tailwind v4 classes by default, or v3 — scales, colour names and syntax differ (for example
p-3.25andshadow-smin v4 vsp-[13px]andshadowin v3). :hover,:focus,::before,:first-child,[aria-expanded="true"],@media (min-width: 768px), dark mode and@supportsbecome variants likehover:,before:,first:,aria-expanded:,md:,dark:andsupports-[…]:..card:hover .titlebecomesgroup-hover:(addinggroupto.card) andinput:checked + labelbecomespeer-checked:.- Colours in hex, rgb(), hsl() or OKLCH are matched to the Tailwind palette (v3 hex and v4 colours), with opacity like
bg-black/50; an option picks the nearest palette colour. - Shorthands are merged into Tailwind shortcuts:
px-4,truncate,size-10,line-clamp-3, gradients asbg-linear-to-r from-… to-…. - Anything without an exact class becomes an arbitrary value (
p-[13px],[-webkit-text-stroke:1px]), highlighted so you can review it; close-but-not-identical matches are marked. - The converter is tested against the real Tailwind v4 compiler, so the classes it writes exist. Runs in your browser — your CSS isn’t uploaded.
Step by step
How to convert CSS to Tailwind
- 1
Paste your CSS
Paste a rule, a whole stylesheet or a few declarations into the CSS box — or try the Sample.
- 2
Choose the version
Pick Tailwind v4 or v3, and set a prefix or nearest-colour matching if you need them.
- 3
Review
Classes appear for each selector. Amber classes are arbitrary values; underlined ones are close, not identical.
- 4
Copy
Copy the classes, a class attribute or a JSX className and paste them into your HTML or components.
Features
Everything you need, nothing you don’t
Whole stylesheets
Paste rules, media queries and nested CSS together — classes are grouped by element, with each breakpoint and state in one class list.
Exact, not guessed
13px stays 13px. Values are only replaced by a Tailwind step when it is exactly the same; otherwise you get an arbitrary value.
Honest approximations
Where Tailwind is close but different — like CSS “ease” vs ease-in-out — the class is marked and the difference explained.
Palette matching
Recognises Tailwind colours from design files, including v4’s OKLCH values, and keeps opacity as /50 modifiers.
See where it came from
Hover a class, or open “How each class was made”, to see the CSS declaration behind it.
Ready to paste
Copy the classes, a class="" attribute or a JSX className for each selector, with your project’s prefix if it uses one.
Examples
| CSS | Tailwind v4 |
|---|---|
display: flex; align-items: center; gap: 8px | flex items-center gap-2 |
padding: 12px 24px | py-3 px-6 |
margin: 0 auto; max-width: 768px | my-0 mx-auto max-w-3xl |
color: #1e293b; background: rgba(0,0,0,.5) | text-slate-800 bg-black/50 |
border: 1px solid #e5e7eb; border-radius: 8px | border border-gray-200 rounded-lg |
overflow: hidden; text-overflow: ellipsis; white-space: nowrap | truncate |
.btn:hover { background: #1d4ed8 } | hover:bg-blue-700 |
@media (min-width: 768px) { .a { padding: 32px } } | md:p-8 |
padding: 13px | p-3.25 (v4) · p-[13px] (v3) |
Tips
Keep @keyframes and @font-face in your CSS (or in your Tailwind theme) — the converter lists them as skipped and you can use animate-[…] and font-[…] to refer to them.
In Tailwind v4, dark: follows the system setting unless you set up class-based dark mode. Tailwind’s preflight already makes borders solid, so border-solid is left out.
FAQ
Frequently asked questions
How do I convert CSS to Tailwind?
Does it support Tailwind v4?
p-4! vs v3 !p-4 for important, for example).Why are some classes like p-[13px]?
Will hex colours become Tailwind colour names?
Does it convert media queries and :hover?
Is my CSS uploaded?
Keep going
Related tools
CSS Flexbox & Grid Playground
Learn and build CSS flexbox and grid layouts visually: try every property, watch items move, draw grid areas, then copy CSS, HTML, Tailwind or React code.
CSS Box Shadow Generator
Free CSS box-shadow generator: build smooth layered shadows, edit each layer, start from Tailwind or Material presets, and copy CSS, Tailwind or React.
Bento Grid Generator
Free bento grid generator: draw tiles with the mouse, preview desktop, tablet and phone, and copy responsive CSS Grid, Tailwind or React code.
CSS Glassmorphism Generator
Free glassmorphism generator: design frosted glass with blur, tint, border and grain, check text contrast live, and copy CSS, Tailwind or React code.
Scroll Animation Generator
Free scroll animation generator: fade, slide, zoom and reveal effects with CSS scroll-driven animations, parallax and progress bars, plus a Firefox fallback.
JSON Formatter & Validator
Format, validate, minify and repair JSON online. Get the exact line and column of every error, a collapsible tree view and sorted keys — private, in-browser.
Last updated Report a problem or suggest a feature