Home/Tools/Utilities/CSS to Tailwind Converter
Utilities · Generator

CSS to Tailwind Converter

Convert CSS declarations to Tailwind CSS utility classes with 200+ property mappings.

CSS Input

Paste CSS declarations (properties and values, without selectors or braces)

Options

Tailwind Classes

18 converted
flexitems-centerjustify-betweengap-4py-6px-8my-0mx-autobg-whiterounded-xlshadow-[0 4px 6px -1px rgba(0,0,0,0.1)]text-basefont-semiboldtext-neutral-900borderborder-gray-200w-fullmax-w-2xl
Converted Classes
/* Original CSS */
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
padding: 24px 32px;
margin: 0 auto;
background: #ffffff;
border-radius: 12px;
box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
font-size: 16px;
font-weight: 600;
color: #1d1d1f;
border: 1px solid #e5e7eb;
width: 100%;
max-width: 640px;
100%
Free, no
sign-up needed
0
Code written
by hand
85+
CSS tools
in one place
<1s
Copy-ready
CSS instantly
What is this

What is the CSS to Tailwind Converter?

Convert CSS properties to Tailwind CSS utility class equivalents. Speed up migration from handwritten CSS to Tailwind.

Everything runs locally in your browser. Adjust the controls above, preview instantly, and copy clean, production-ready CSS — no account, no upload.

How to use

Using the CSS to Tailwind Converter

Everything lives in the panel at the top of this page. There is nothing to install — it all runs right here in your browser.

1

Paste your CSS rule

Paste a CSS declaration block (the property-value pairs inside {}). The tool converts each property to its Tailwind equivalent.

2

Review the output

Some CSS values do not have a direct Tailwind equivalent and will be shown as arbitrary values: [value]. Review these for accuracy.

3

Copy and paste into HTML

Add the Tailwind class string to your HTML element's class attribute.

The output

What the generated code looks like

Clean, production-ready CSS — no vendor bloat, no unnecessary declarations.

tailwind-output.html
<!-- Input CSS -->
<!--
.card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
-->

<!-- Tailwind classes equivalent -->
<div class="flex flex-col gap-4 p-6 bg-white rounded-xl shadow-sm">
  <!-- content -->
</div>

Tailwind uses a default spacing scale where 1 unit = 4px. padding: 24px becomes p-6 (6 x 4px = 24px). gap: 16px becomes gap-4 (4 x 4px = 16px).

Copy & paste

Ready-to-use CSS patterns

Drop any of these straight into your project — no modifications needed.

Hover and focus states

Pseudo-class rules become prefixed utilities on the same element.

styles.css
/* CSS */
.btn { background: #2563eb; }
.btn:hover { background: #1d4ed8; }
.btn:focus-visible { outline: 2px solid #93c5fd; }

<!-- Tailwind -->
<button class="bg-blue-600 hover:bg-blue-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-blue-300">

Responsive rules

Mobile-first: unprefixed classes apply everywhere, md: and lg: override from that breakpoint up.

styles.css
/* CSS */
.grid { display: grid; grid-template-columns: 1fr; }
@media (min-width: 768px) { .grid { grid-template-columns: repeat(3, 1fr); } }

<!-- Tailwind -->
<div class="grid grid-cols-1 md:grid-cols-3">
Common mistakes & fixes

Common mistakes & how to fix them

A few habits trip people up. Here is what to watch for — and the exact fix.

Converting component CSS line by line

Long class strings repeated on every instance of a component become hard to maintain.

Fix: Convert once, then keep the classes in a single component (React, Vue, Blade) or, sparingly, an @apply rule.

Losing the cascade order

In CSS a later rule can override an earlier one; in Tailwind two conflicting utilities on one element are resolved by stylesheet order, not class order.

Fix: Keep only one utility per property on an element, or use a helper such as tailwind-merge when classes are combined dynamically.

Expecting a 1:1 CSS to Tailwind conversion

Tailwind's spacing scale, colour palette, and breakpoints are opinionated. Custom values (non-scale colours, arbitrary spacing) become [arbitrary] classes.

Fix: Use the converter for rough migration. Review arbitrary values and either add them to tailwind.config.js as custom tokens or refactor to the nearest Tailwind scale value.

Pro tips

Pro tips for better results

★

Tailwind arbitrary values [value] are an escape hatch, not a pattern

Frequent arbitrary values (bg-[#0071e3], p-[13px]) defeat the purpose of a design system. Add frequently used values to tailwind.config.js theme extension instead.

FAQ

Frequently asked questions

Not necessarily. Tailwind is fastest for layout, spacing and typography. Complex animations, third-party widget overrides and highly dynamic styles are often clearer as regular CSS alongside Tailwind.
Square brackets are Tailwind arbitrary values, used when a CSS value is not on Tailwind’s default scale — for example p-[13px] or bg-[#0071e3]. If the same value repeats, add it to your Tailwind theme as a named token instead.
CSS inside @media blocks maps to Tailwind responsive prefixes: md: lg: xl:. Enter the media query styles separately and prepend the appropriate breakpoint prefix to each class.
This tool converts in one direction (CSS to Tailwind). To see the CSS behind a Tailwind class, inspect the element in your browser DevTools — the Styles panel shows the computed declarations — or look the class up in the Tailwind documentation.

From the blog

Read more →