tailwindconvert
GitHub

Tailwind CSS Converter

Convert between plain CSS and Tailwind CSS utility classes instantly. Bidirectional, free, and runs entirely in your browser.

No data sent to any server — 100% client-side conversion

CSS Input
Tailwind Classes Output
Tailwind classes will appear here...

FAQ

Q. Which Tailwind version does this follow?

A. Tailwind CSS v4. Class names follow the v4 scale, for example 2px radius is rounded-xs and the small shadow is shadow-xs. Results were checked against the tailwindcss v4.2 compiler.

Q. What happens to values that are not on Tailwind's scale?

A. They become arbitrary values, for example padding: 7px becomes p-[7px] and filter: blur(4px) becomes [filter:blur(4px)]. Even pixel values on the 4px grid use the v4 spacing scale, e.g. 18px becomes 4.5.

Q. Are media queries and nested rules converted?

A. No. Only plain rules and bare declarations are converted. Convert the rules inside a media query separately and add a variant such as md: yourself.

Q. Can I paste the result straight into production code?

A. Use it as a starting point. Check that the classes fit your design system, especially when the output contains arbitrary values or you use a custom theme.

Ad Space

Common CSS to Tailwind Patterns

Quick reference table for the most frequently used CSS properties and their Tailwind CSS equivalents.

CategoryCSSTailwind
Layoutdisplay: flexflex
Layoutdisplay: gridgrid
Layoutdisplay: nonehidden
Layoutdisplay: blockblock
Layoutposition: relativerelative
Layoutposition: absoluteabsolute
Layoutposition: fixedfixed
Layoutposition: stickysticky
Flexboxflex-direction: columnflex-col
Flexboxjustify-content: centerjustify-center
Flexboxjustify-content: space-betweenjustify-between
Flexboxalign-items: centeritems-center
Flexboxflex-wrap: wrapflex-wrap
Flexboxflex: 1 1 0%flex-1
Flexboxgap: 1remgap-4
Spacingpadding: 1remp-4
Spacingpadding: 0.5rem 1rempx-4 py-2
Spacingmargin: 0 automx-auto
Spacingmargin-top: 1remmt-4
Spacingmargin-bottom: 2remmb-8
Sizingwidth: 100%w-full
Sizingheight: 100%h-full
Sizingmax-width: 80remmax-w-7xl
Sizingmin-height: 100vhmin-h-screen
Typographyfont-size: 0.875remtext-sm
Typographyfont-size: 1.25remtext-xl
Typographyfont-size: 1.5remtext-2xl
Typographyfont-weight: 700font-bold
Typographyfont-weight: 600font-semibold
Typographytext-align: centertext-center
Typographytext-transform: uppercaseuppercase
Typographyline-height: 1.5leading-normal
Bordersborder-radius: 0.5remrounded-lg
Bordersborder-radius: 9999pxrounded-full
Bordersborder-width: 1pxborder
Bordersborder-style: solidborder-solid
Effectsbox-shadow: 0 1px 3px ...shadow-sm
Effectsbox-shadow: 0 10px 15px ...shadow-lg
Effectsopacity: 0.5opacity-50
Interactivitycursor: pointercursor-pointer
Interactivityoverflow: hiddenoverflow-hidden
Interactivityuser-select: noneselect-none
Transitionstransition-property: alltransition-all
Transitionstransition-duration: 300msduration-300

Why Use a Tailwind CSS Converter?

What is Tailwind CSS?

Tailwind CSS is a utility-first CSS framework that provides low-level utility classes to build custom designs without writing traditional CSS. Instead of writing display: flex; justify-content: center;, you simply add flex justify-center as CSS classes directly in your HTML. This approach speeds up development, reduces CSS file size through purging unused styles, and makes it easy to maintain consistent designs across large projects.

Why Convert CSS to Tailwind?

Converting existing CSS to Tailwind utility classes is one of the most common tasks when migrating a project to Tailwind CSS. If you have an existing codebase with traditional stylesheets, a CSS to Tailwind converter helps you quickly translate your styles into utility classes. This is especially useful when refactoring legacy code, onboarding new team members who are learning Tailwind, or when you find a CSS snippet online and want to use it in your Tailwind project.

Why Convert Tailwind to CSS?

The reverse direction is equally valuable. Sometimes you need to understand what CSS a Tailwind class actually generates, or you need to extract styles from a Tailwind project into plain CSS for use in a non-Tailwind environment. A Tailwind to CSS converter lets you quickly see the underlying CSS properties for any combination of utility classes. This is helpful for debugging, learning, and for projects that need to support both Tailwind and traditional CSS workflows.

How This Tool Works

This Tailwind CSS converter runs entirely in your browser. It uses a comprehensive mapping dictionary covering the most common CSS properties and their Tailwind equivalents, including layout, spacing, typography, colors, borders, shadows, flexbox, grid, and more. Simply paste your CSS or Tailwind classes in the input panel, and the converted output appears instantly. The converter handles plain selectors and padding/margin shorthands. Values that are not on Tailwind's scale become arbitrary values such as p-[7px], and properties without a named utility become arbitrary properties such as [filter:blur(4px)]. Media queries and nested rules are not converted.

Supported Properties

The converter supports over 60 of the most commonly used CSS properties, including display, position, padding, margin, width, height, font-size, font-weight, color, background-color, border-radius, box-shadow, flexbox properties like justify-content and align-items, grid properties like grid-template-columns and col-span, overflow, opacity, cursor, z-index, transitions, and many more. Output follows Tailwind CSS v4 class names (for example rounded-xs and shadow-xs) and maps pixel and rem values to the v4 spacing scale, where 1 unit is 0.25rem (4px).

Tips for Using the Converter

  • You can paste full CSS rules with selectors, or just bare property declarations without selectors.
  • Use the mode toggle button to switch between CSS-to-Tailwind and Tailwind-to-CSS directions.
  • Click the Copy button to quickly copy the output to your clipboard.
  • Check the reference table below the converter for common patterns you can memorize over time.
  • For responsive designs, remember that Tailwind uses prefix modifiers like sm: , md: , and lg: instead of media queries.