Ttooleras
🌊

Tailwind CSS Converter

CSS Tools

Convert between plain CSS and Tailwind utility classes. Paste CSS rules and get the equivalent Tailwind classes, or reverse the process to see what utilities expand to.. Free, private — all processing in your browser.

Advertisement

Migrating a codebase from hand-written CSS to Tailwind is mostly a mechanical task: translate each padding: 1rem to p-4, each display: flex to flex, and so on. Doing it by hand file by file is tedious and error-prone, especially when your CSS uses pixel values, custom colors, or mixed units. This converter automates the translation in both directions so you can paste CSS and get Tailwind classes, or paste Tailwind and see the CSS it expands to.

The mapping covers Tailwind's full utility vocabulary: spacing (margin and padding), sizing (width, height, max-*), typography (font-size, line-height, font-weight, letter-spacing), colors (background, text, border, ring), layout (flex, grid, gap, display), positioning, borders, shadows, opacity, transitions, and transforms. When a CSS value matches Tailwind's default scale, the converter uses the standard class. When it doesn't, the output uses arbitrary values syntax (p-[13px], bg-[#1a2b3c]) so the result is precise even for off-scale values.

Two use cases dominate. The first is migration: paste a block of CSS from a legacy stylesheet and get Tailwind classes to sprinkle into JSX or templates. The second is learning: paste a Tailwind class string and see the equivalent CSS, so you understand exactly what each utility does. A third bonus is auditing — pasting your component's current Tailwind classes and seeing the computed CSS helps spot redundancy and conflicts. Combined with the CSS formatter and Tailwind color finder, this tool is the quickest path between hand-written CSS and utility-first styles.

Tailwind CSS Converter — key features

Bidirectional conversion

CSS to Tailwind and Tailwind to CSS in a single tool.

Arbitrary value support

Off-scale values render as arbitrary-value utilities like p-[13px] for precision.

Responsive variant detection

Recognizes media queries in CSS and translates to Tailwind's responsive prefixes.

Pseudo-state mapping

Handles :hover, :focus, :disabled, and dark-mode variants.

Tailwind v3 and v4 output

Pick the Tailwind version matching your project.

Side-by-side preview

See CSS and Tailwind classes simultaneously with a synced preview.

Unused class detection

Identifies redundant or conflicting Tailwind classes in your input.

How to use the Tailwind CSS Converter

  1. 1

    Paste CSS or Tailwind

    Drop a CSS rule set, a component's class string, or a full stylesheet.

  2. 2

    Pick direction

    CSS-to-Tailwind for migration; Tailwind-to-CSS for learning or auditing.

  3. 3

    Select Tailwind version

    v3 is the current stable, v4 for newer projects with native CSS variables.

  4. 4

    Review the output

    The converter shows the result with warnings for unmapped properties or ambiguous values.

  5. 5

    Copy into your project

    Paste Tailwind classes into your JSX/template or CSS rules into your stylesheet.

Common use cases for the Tailwind CSS Converter

Migration

  • :
  • :
  • :

Learning

  • :
  • :
  • :

Team onboarding

  • :
  • :
  • :

Design-to-code

  • :
  • :
  • :

Tailwind CSS Converter — examples

Spacing

padding 1rem

Input
padding: 1rem;
Output
p-4

Flex layout

Centered flex row

Input
display: flex; align-items: center; justify-content: center;
Output
flex items-center justify-center

Colors

Tailwind blue-500

Input
background-color: #3b82f6;
Output
bg-blue-500

Arbitrary value

Off-scale padding

Input
padding: 13px;
Output
p-[13px]

Responsive

Medium-screen grid

Input
@media (min-width: 768px) { grid-template-columns: repeat(3,1fr); }
Output
md:grid-cols-3

Technical details

Tailwind CSS generates utility classes from a configuration that defines scales for spacing, colors, fonts, breakpoints, and more. In Tailwind v3, the default spacing scale is 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, ... where each number corresponds to multiples of 0.25rem (4px at the default 16px base). p-4 produces padding: 1rem, m-2 produces margin: 0.5rem, and so on. Tailwind v4 (2024 release) refines this with improved arbitrary values, faster builds, and native CSS variables.

Non-spacing utilities follow similar patterns. Colors use a semantic name plus a shade number: bg-blue-500 references the Tailwind blue palette at the 500 weight. Typography utilities map text-xs through text-9xl to specific font-size/line-height pairs. Breakpoints prefix classes (md:flex, lg:grid-cols-3) for responsive variants. Pseudo-class variants (hover:, focus:, active:) and state variants (dark:, disabled:) apply additional CSS conditions.

For any CSS value that doesn't match Tailwind's default scale, the converter uses arbitrary value syntax: p-[13px], bg-[#1a2b3c], text-[2.3rem]. These work in Tailwind v3.1+ JIT mode and allow full flexibility while keeping the utility-first approach. The tool also recognizes common CSS patterns that map to Tailwind's composable utilities — flex items-center justify-center for centering, grid grid-cols-3 gap-4 for grids — and suggests these combinations rather than individual properties.

Common problems and solutions

Color matching

Tailwind's default palette may not include your brand colors. Arbitrary values work but consider extending the theme config.

Complex selectors

Deep descendant selectors cannot be expressed as utility classes. Use @apply in a component class for those cases.

Animations

Complex keyframe animations need custom keyframes in tailwind.config.js. The converter flags these.

Specificity

Utility-first flattens specificity. Migrating from complex cascade requires careful testing.

!important

Tailwind's `!` prefix (e.g., !p-4) exists but overusing it defeats the utility-first approach.

Custom properties

CSS custom properties (var(--x)) translate to arbitrary values. Large CSS var usage benefits from Tailwind v4's native variable support.

Tailwind CSS Converter — comparisons and alternatives

Manual CSS-to-Tailwind migration is tedious and mistake-prone. Copilot and AI tools can convert but often hallucinate class names or miss arbitrary values. Official Tailwind documentation explains utilities but doesn't automate conversion. This tool is purpose-built for bidirectional conversion, supports both Tailwind v3 and v4, handles arbitrary values, responsive variants, pseudo-states, and dark mode. Fast, accurate, and the quickest way to migrate a codebase or learn Tailwind from CSS intuition.

Frequently asked questions about the Tailwind CSS Converter

Can this convert my entire stylesheet?

Rule by rule yes. Complex CSS architecture (nested selectors, complex cascades) may not translate cleanly and may benefit from refactor during migration.

What about custom Tailwind config?

The converter assumes default Tailwind config. If you have extended theme with custom colors or spacing, the output may use arbitrary values where matches exist in your config.

Tailwind v3 or v4 — which should I use?

Stick with v3 for production projects unless you are starting fresh. v4 is newer but adoption patterns are still settling.

Does this handle dark mode?

Yes. CSS inside @media (prefers-color-scheme: dark) or body.dark selectors maps to Tailwind's dark: prefix.

Can I convert Bootstrap to Tailwind?

The converter handles raw CSS from any source, including Bootstrap output. Semantic component classes need manual refactor to utility equivalents.

Will the output work with Tailwind JIT?

Yes. Arbitrary values require JIT mode which is default in Tailwind v3+. Turn off JIT and arbitrary values break.

How about CSS-in-JS libraries?

Emotion/styled-components CSS translates the same way. Copy the CSS string and paste into this converter.

Can I convert to another utility framework?

This tool targets Tailwind specifically. UnoCSS and Windi have similar mappings but different class names.

Additional resources

Advertisement

Related tools

All CSS Tools

Learn more

Explore more tools

200+ free tools that run in your browser.

Browse all tools →