CSS to Tailwind Converter
Convert your CSS code to TailwindCSS utility classes with this simple tool. Paste your CSS below or upload a file to get started.
Supports nested CSS syntax with & for nesting selectors.
CSS Input
Toggle between "Closest Tailwind Defaults" (e.g., p-6) and "Exact Custom Values" (e.g., p-[24px]).
Tailwind Output
Converted Tailwind classes will appear here
How to use the CSS to Tailwind Converter
These are the steps to use the CSS to Tailwind Converter:
- Paste your CSS code or upload a CSS file in the left editor area
- Next, you can choose between "The Tailwind Defaults" or "Exact Custom Values" mode by using the checkbox
- Click the "Convert to Tailwind" button.
- The converted Tailwind classes will appear in the right editor area
- You can make some changes to the output if you want to
- Copy the output and use it in your project.
About CSS to Tailwind Conversion
How It Works
This tool parses your CSS using PostCSS and maps the properties to equivalent Tailwind utility classes. It handles common properties like colors, spacing, typography, and more. It also supports pseudo-classes, media queries, and supports queries.
Supported CSS Features
- Nested Selectors: Using
&for nesting - Pseudo-classes:
:hover,:focus, etc. - Media Queries: Responsive design with
@media - Supports Queries: Feature detection with
@supports
FAQ
Frequently Asked Questions
How can I convert an entire CSS file at once?
You can convert an entire CSS file at once by uploading the file in the left editor area. Once the file is uploaded, you can click the "Convert to Tailwind" button. It will convert the entire file by the tailwind defaults. However, if you want to use the exact custom values, you can use the "Exact Custom Values" checkbox.
Can this tool convert CSS preprocessor syntax like SASS or LESS?
No, the tool only supports standard CSS syntax. If you want to convert SASS or LESS, you need to compile your code to standard CSS before using the conversion tool.
Can this tool handle custom CSS properties (CSS variables)?
No, this tool does not support custom CSS properties (CSS variables). However, you can use the "Exact Custom Values" checkbox to convert the custom CSS properties to Tailwind classes. And you can make some changes to the output too to get the best results.
Can I use the generated Tailwind classes immediately in my project?
Yes, you can use the generated Tailwind classes immediately in your project. If you using the "Exact Custom Values" checkbox, you can make some changes to the output too to get the best results. ANd copy past the code in your tailwind css file. But if you using it in jsx like Next.js, then remove the @apply and copy paste the code in the className.
Are the media queries and responsive designs supported?
The conversion is not 100% accurate. It might not convert the media queries into breakpoints and create issues with responsive designs. But you can make some changes to the output too to get the best results.
What if the tool doesn't convert a specific CSS property or class?
If the tool is unable to convert a specific CSS property or class, it means that the property is not supported by Tailwind CSS. You can use the "Exact Custom Values" checkbox to convert the property to Tailwind classes. Once you have the exact output of it, use the tailwind @apply directive with the original CSS in your stylesheet.
Whats the limit of the tool?
There is no limit of the tool. You can convert as much CSS as you want. It is recommended to spilt the css code into smaller parts and convert them separately.
Can I upload a CSS file to the tool?
Yes, you can upload a CSS file to the tool. The tool will convert the CSS file to Tailwind classes. However, it is recommended to use smaller parts of the css code to get the best results.