CSS to Tailwind Converter
Convert CSS properties to equivalent Tailwind CSS utility classes. Covers display, spacing, typography, flexbox, grid, and more. Free, browser-based, instant conversion.
- Runs in your browser
- Tool input is not uploaded to ZeroTool servers
- Free · No Sign-Up
Scan with WeChat to share this tool
Examples, details and FAQ Worked examples, how it compares with other tools, and answers to common questions.
Worked Examples
Flexbox card
Input CSS:
.card {
display: flex;
flex-direction: column;
align-items: center;
gap: 1rem;
padding: 1.5rem;
border-radius: 0.5rem;
}
Output Tailwind:
/* .card */
flex flex-col items-center gap-4 p-6 rounded-lg
Typography
Input CSS:
font-size: 1.125rem;
font-weight: 600;
text-align: center;
text-transform: uppercase;
letter-spacing: 0.05em;
Output Tailwind:
text-lg font-semibold text-center uppercase tracking-wider
Limitations
This tool uses a built-in mapping table rather than a full CSS parser.
Complex values such as custom colors, multi-value transitions, CSS variables, and calc() expressions are left as /* keep: ... */ comments for you to handle manually or convert using Tailwind's arbitrary value syntax (p-[13px], text-[#ff6600]).
Example: A Button With a Hover State and a Media Query
.btn {
margin: 0 auto;
padding: 16px 24px;
color: #3b82f6;
background-color: #ffffff;
width: 50%;
max-width: 64rem;
line-height: 1.5;
border: 1px solid #e5e7eb;
margin-top: 13px;
transition: all 0.2s;
}
.btn:hover { background-color: #2563eb; }
@media (min-width: 768px) { .btn { padding: 2rem; } }
converts to
/* .btn */
my-0 mx-auto py-4 px-6 text-blue-500 bg-white w-1/2 leading-normal border border-solid border-gray-200 transition-all duration-200
/* keep: max-width: 64rem */
/* keep: margin-top: 13px */
/* .btn:hover */
bg-blue-600
/* .btn (md) */
md:p-8
What happened, and how to finish the class list (Tailwind docs):
16px 24pxbecamepy-4 px-6: pixel values are divided by 16 to get rem, and one spacing step is 0.25rem.#3b82f6,#ffffff, and#2563ebmatched default palette colors (blue-500,white,blue-600).border: 1px solid #e5e7ebbecameborder border-solid border-gray-200. Every part of the shorthand (width, style, color) must be in the table; if one is not, the whole declaration is kept as a comment, so no part is dropped.transition: all 0.2sbecametransition-all duration-200. The duration is always written, because a Tailwindtransition-*class alone means 150 ms. Tailwind's classes also set the timing curvecubic-bezier(0.4, 0, 0.2, 1), where CSS defaults toease; addease-[ease]if the curve must match exactly.max-width: 64remwas kept althoughmax-w-5xlis 64rem. Values that do not match the tool's table are kept even when a class exists..btn:hoverbecame its own group. Add thehover:prefix:hover:bg-blue-600.- The rule inside
@media (min-width: 768px)becamemd:p-8: 768px is the defaultmdbreakpoint. Other media queries label the group but get no prefix.
Finished classes:
<button class="mx-auto mt-[13px] mb-0 py-4 px-6 md:p-8 text-blue-500 bg-white hover:bg-blue-600
w-1/2 max-w-5xl leading-normal border border-solid border-gray-200
transition-all duration-200">
Example: Common Declarations Without a Selector
padding: 0.5rem 1rem;
margin: 0;
top: 0;
z-index: 10;
overflow: hidden;
position: sticky;
opacity: 0.5;
cursor: pointer;
grid-template-columns: repeat(3, 1fr);
flex: 1;
height: 100vh;
font-size: 14px;
converts to
py-2 px-4 m-0 top-0 z-10 overflow-hidden sticky opacity-50 cursor-pointer grid-cols-3 flex-1 h-screen text-sm
Arbitrary Values
For a value outside the default scale, Tailwind accepts the value in square brackets: mt-[13px], max-w-[60rem], text-[#ff6600], grid-cols-[200px_1fr] (an underscore stands for a space). The converter never writes these; it leaves a keep comment so you can decide between an arbitrary value and the nearest scale step.
Limits
- Values are looked up in a mapping table, not computed: a value outside the table is kept as a comment even when a class exists (see
max-widthabove). box-shadowmaps only the default shadows of Tailwind v3 (shadow-smtoshadow-2xlandshadow-inner, with the values written as in the v3.4.17 docs). Any other shadow is kept as a comment, including the same shadow with its color written asrgba(0, 0, 0, 0.05).grid-template-columnsandgrid-template-rowsmap onlyrepeat(N, 1fr)andrepeat(N, minmax(0, 1fr))with N from 1 to 12, the range of Tailwind v3'sgrid-cols-*andgrid-rows-*; a larger N is kept as a comment. Tailwind definesgrid-cols-Nasrepeat(N, minmax(0, 1fr)): a column whose content is wider than an equal share grows with1fr, but stays an equal share with the class, and the content overflows.grid-column: span 2 / 4(an end line after the span) becomescol-span-2, and the end line is lost;grid-rowworks the same way. Check these by hand.- Font size classes set a line height too:
text-lgisfont-size: 1.125rem; line-height: 1.75rem, so check the line height after converting. - Selectors with pseudo-classes become separate groups; no
hover:orfocus:prefixes are written. - Only
@media (min-width: …)with a default breakpoint width (640px, 768px, 1024px, 1280px, 1536px or the same in rem) becomes a prefix. Other media queries,@supports, and container queries only label the group. - A transition list with commas,
cubic-bezier(), or a duration outside the scale (0, 75, 100, 150, 200, 300, 500, 700, 1000 ms) is kept as a comment. - CSS variables,
calc(), and colors outside the default palette are kept as comments. - Tailwind v4 renamed some utilities (for example the shadow and radius scales). Check the upgrade guide if you use v4.
FAQ
What CSS properties are supported?
The built-in table covers the common properties: display, position, overflow, flexbox, grid, alignment, spacing (margin, padding, gap), sizing (width, height), typography (font size and weight, line height, letter spacing, text alignment), colors that match the default palette, borders, border radius, box shadow, opacity, z-index, cursor and transitions. A value is converted only when the table lists it; any other value is kept as a comment. For example, box-shadow becomes a class only for the default shadows in the Tailwind v3.4.17 docs, and grid-template-columns only for repeat(N, 1fr) or repeat(N, minmax(0, 1fr)) with N from 1 to 12.
What happens to properties that can't be mapped?
They are written as /* keep: property: value */ comments, with the case you typed, so you can see which declarations need manual work; the tool does not write arbitrary values such as p-[13px]. Some classes are not exact equivalents and get no comment, for example: text-lg also sets a line height; transition-* classes also set Tailwind's timing curve, and transition-colors covers several color properties; repeat(N, 1fr) becomes grid-cols-N, which is repeat(N, minmax(0, 1fr)), so a column with wider content no longer grows; grid-column: span 2 / 4 becomes col-span-2, which drops the end line. Check those by hand.
Can I paste a full CSS rule with a selector?
Yes. You can paste one or more CSS rule blocks (e.g. .card { ... }). The converter outputs each selector's classes in a comment-labeled group. You can also paste bare declarations without a selector.
Does it support Tailwind v4?
The table uses Tailwind v3's class names and default palette. Tailwind v4 keeps most of those names, with three differences that affect the output: its default colors are redefined in OKLCH, so text-blue-500, the tool's match for #3b82f6, is a slightly different blue in v4; its radius scale moved, so rounded-sm, which the tool writes for 2px, is 0.25rem in v4 (0.125rem is rounded-xs there); and its shadow scale moved, so shadow-sm, which the tool writes for 0 1px 2px 0 rgb(0 0 0 / 0.05), is a larger shadow in v4 (that value is shadow-xs there; the bare shadow class is unchanged). If you use v4, check colors, radii and shadows against the upgrade guide.
Is my CSS sent to a server?
No. The conversion runs in this browser tab with the built-in mapping table; the CSS is not sent to a server and is not saved in browser storage. When you click Convert to Tailwind (or press Ctrl/⌘+Enter), the page analytics record the tool name and the action convert, not the CSS.