Skip to main content

CSS to Tailwind CSS Converter

Convert traditional CSS properties into utility Tailwind CSS classes

CSS to Tailwind Converter:

149 / 65,536 characters. Selectors and responsive states are not converted.

Tailwind CSS Utility Classes

Was this CSS to Tailwind CSS Converter helpful?

Help us keep tools reliable, fast, and bug-free.

What you can do with CSS to Tailwind CSS Converter

  • Convert css to tailwind
  • Transform css properties to tailwind

What this conversion does

Convert CSS declarations into Tailwind utility and arbitrary-property classes without preserving selector, pseudo-class, or media-query behavior.

Example input

.card { margin-top: 1rem; padding: 1rem; font-weight: bold; }

Example output

mt-4 p-4 font-bold (with arbitrary-value classes like mt-[13px] when no scale step matches)

Practical workflow

  1. Paste a declaration list or a simple CSS rule containing the properties you want to migrate.
  2. Review the mapped utilities and arbitrary-property classes; the converter does not transfer selector or media-query behavior.
  3. Apply the classes to the intended element, add any needed Tailwind variants such as hover: or md:, then remove the migrated declarations.

Common use cases

  • Migrate a legacy stylesheet to Tailwind utility classes incrementally.
  • Learn the Tailwind equivalent of a CSS property you already know.
  • Convert design-tool CSS output into utilities that match your codebase.

Important notes and limitations

  • Values that do not sit on Tailwind's default scale are emitted as arbitrary-value classes (for example mt-[13px]); consider rounding to scale steps for consistency.
  • The converter reads declarations inside simple CSS rules or a declaration list. It does not preserve selectors, cascade, specificity, pseudo-classes, or media queries; reapply those behaviors with Tailwind variants yourself.
  • Unmapped declarations use arbitrary-property classes, with value whitespace represented by underscores. Complex values containing semicolons and nested at-rules need manual review.

Tailwind CLI & PostCSS build integration

Tailwind CLI compile single file

npx tailwindcss -i ./src/input.css -o ./dist/output.css --minify

Compiles source CSS containing @tailwind directives into a minified production stylesheet.

Find unused Tailwind classes with purge

npx tailwindcss --content './src/**/*.{html,js,tsx}' --watch

Scans project source files and generates only the CSS classes that are actually referenced in templates.

Check Tailwind version

npx tailwindcss --help

Displays Tailwind CLI installation parameters, build flags, and engine version.

CSS Property to Tailwind Utility Mapping Reference

Standard CSS DeclarationTailwind Equivalent ClassArbitrary Value SyntaxConversion Feasibility
display: flex; justify-content: space-between;flex justify-betweenN/A100% direct 1:1 utility mapping
margin: 16px 24px; padding: 12px;my-4 mx-6 p-3m-[16px_24px] p-[12px]Direct mapping with standard 4px scale
background-color: rgba(59, 130, 246, 0.5);bg-blue-500/50bg-[#3b82f6]/50Native Tailwind v3+ opacity modifier support
width: calc(100% - 32px);w-[calc(100%-2rem)]w-[calc(100%-32px)] (No spaces allowed)Requires bracketed arbitrary syntax without internal whitespace
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);shadow-mdshadow-[0_4px_6px_-1px_rgba(0,0,0,0.1)]Mapped to standard design token or arbitrary string with underscores

CSS to Tailwind conversion & JIT compiler troubleshooting

Arbitrary value not applied (e.g. w-[calc(100% - 20px)] fails)

Cause: Tailwind CSS JIT compiler breaks on whitespace inside square brackets because spaces delimit class names in HTML.

Solution: Remove spaces or replace them with underscores: use 'w-[calc(100%-20px)]' or 'grid-cols-[1fr_2fr]'.

Complex CSS pseudo-elements (::before, ::after) not showing up

Cause: Tailwind requires 'before:content-['']' or 'before:block' for pseudo-elements to render in DOM.

Solution: Add 'before:content-[""] before:block' alongside your position and dimension utility classes.

CSS variable var(--my-theme-color) not working in arbitrary class

Cause: Invalid syntax in bracketed class (e.g. 'bg-[var(--my-color)]').

Solution: Use 'bg-(--my-theme-color)' in Tailwind v4 or 'bg-[var(--my-theme-color)]' without outer curly braces.

Continue your workflow

  • SVG to React — Convert raw SVG graphics into React JSX components styled with Tailwind CSS utility classes.
  • Color Converter — Translate HEX and RGB color values into Tailwind design token palette names.
  • Color Contrast Checker — Verify WCAG AA and AAA accessibility contrast ratios for Tailwind UI combinations.
  • Format Converter — Convert theme configuration data between JSON, YAML, and CSS variables.

Frequently asked questions

How accurate is a CSS to Tailwind conversion?

Common declarations such as spacing, typography, display, and flexbox map to utility classes. Other declarations become arbitrary classes. Selectors, cascade, media queries, and pseudo-class behavior are not preserved and must be re-expressed with Tailwind variants.

Does it handle values that are not in Tailwind's scale?

Yes — they are emitted as arbitrary-value utilities such as mt-[13px] or text-[#1a2b3c], which Tailwind supports natively.

Is my CSS uploaded anywhere?

No. The conversion is computed locally in your browser.