CSS to Tailwind Converter
Paste a rule like .card { padding: 16px; border-radius: 12px; } and get p-4 rounded-xl. The converter targets Tailwind CSS v4. It reads rules, nested rules, comments, strings and !important, turns :hover and @media (min-width: 768px) into hover: and md: variants, and writes a value that is off the scale as an arbitrary value. Whatever it cannot express exactly is listed, not guessed.
How to Convert CSS to Tailwind
- Paste CSS into CSS Input: bare declarations or whole rules, including
:hoverrules and@mediablocks. The class list updates as you type, and Convert to Tailwind runs it again. - Turn Prefer arbitrary values off to allow only utilities on the Tailwind scale, or leave it on to get classes like
p-[18px]and[transition:all_0.3s]for everything else. - Read the line under the output: how many classes were produced, how many declarations were not converted, and, with Include unsupported list on, each one with the reason.
- Press Copy to Clipboard to copy the class list alone, then paste it into a
classattribute.
Where one class is not the same CSS
Tailwind utilities often set more than one property. text-3xl sets a line height as well as a size, so the converter uses a preset size only when your CSS also declares line-height, and otherwise writes text-[30px]. The border width utilities also set border-style, so they are used only when your CSS sets the style in the same context, and otherwise the output is [border-width:2px]. The converter assumes horizontal, left-to-right text, where inline-size is width and px- sets left and right. If your CSS sets direction or writing-mode, it assumes no writing mode: left and right stay separate classes (pl-1 pr-1), and a logical property that could set the same side as a physical one is listed.
Within one context (the same pseudo-classes and media queries), a later declaration replaces an earlier one, !important beats a normal one, and rules are merged as if they style one element, whatever their specificity. So padding: 8px; padding-left: 0 becomes py-2 pr-2 pl-0. Tailwind orders classes by property and variant, not by source order, so declarations that set the same underlying property, such as margin and margin-left or width and inline-size, are listed when both stay in one context or appear in two, such as the base rule and :hover. The exception is mobile-first breakpoints: a base value, then min-width rules at 640, 768, 1024, 1280 or 1536px in ascending order, become sm: to 2xl:.
A selector such as .a .b styles a different element, so it is listed. Pixel values become Tailwind's rem scale at a 16px root: 16px is p-4, which is 1rem, so a project that changes the root font size changes those classes. In v4, rounded-sm is 4px and rounded-xs is 2px, and opacity-50 is opacity: 50%. The tests compile every emitted class with Tailwind 4.1.18 and compare the declarations with your input.