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
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.
Markdown Live Previewer
Write Markdown with a live preview: GitHub tables, task lists, alerts and highlighted code. Export to HTML or PDF — free, private, runs in your browser.
Base64 Encoder & Decoder
Encode text or files to Base64 and decode Base64 back — UTF-8, URL-safe Base64URL, data URLs for images, file type detection. Free, private, no upload.
URL Encoder / Decoder
Encode or decode URLs and query strings online: %20, + and UTF-8 (Hindi, emoji) done right, errors pinpointed, and URL parameters shown in a table.
XML to JSON Converter
Convert XML to JSON and JSON to XML online. Keeps attributes, arrays and leading zeros intact, shows exact error lines and never uploads your data.
DNS Lookup
Free DNS lookup: check A, AAAA, CNAME, MX, NS, TXT, SOA and CAA records of any domain, see SPF and DMARC, and do reverse DNS for an IP address.
Last updated Report a problem or suggest a feature