CSS formatter

Prettify and minify CSS stylesheets with configurable indentation.

Indent

Why format CSS?

Unformatted CSS — whether minified for production, generated by a tool, or hastily written — is painful to read. Properties merge into dense lines, selector specificity is hard to trace, and debugging requires mental parsing before you can even understand the structure. A CSS formatter transforms chaotic stylesheets into clean, consistently indented code in seconds.

Formatting is especially valuable when working with third-party stylesheets, CSS extracted from browser DevTools, or vendor CSS that you need to inspect or modify. It's also useful for standardising code style when onboarding legacy projects that don't have a formatter configured.

CSS minification

Minification removes all unnecessary characters from CSS — whitespace, newlines, comments, and redundant semicolons — without changing the stylesheet's behaviour. A typical CSS file shrinks by 15–30% after minification, and further compression (gzip/brotli) reduces the payload even more.

In production, minified CSS means faster downloads and faster parsing. Every kilobyte matters on mobile networks and for Core Web Vitals scores. Most build tools (webpack, Vite, esbuild, Next.js) minify CSS automatically in production builds, so you rarely need to minify manually — but this tool is handy for one-off tasks or inspecting what the minified output looks like.

Don't minify CSS in your source code. Keep your source formatted and readable, and let the build pipeline handle minification. Source maps bridge the gap, mapping minified production CSS back to your formatted source for debugging.

Frequently asked questions

Does CSS formatting affect performance?
In development, no — browsers parse both formatted and minified CSS at effectively the same speed. In production, you should serve minified CSS to reduce file size and download time. Minification typically reduces CSS file size by 15–30% before gzip compression. However, formatting is essential during development for readability, debugging, and code review. Use formatted CSS in your source code and minify as a build step.
Should I manually format CSS or use a tool?
Use a tool — always. Manual formatting is inconsistent and wastes time. In a real project, use Prettier (the most popular code formatter) with your editor configured to format on save. For CI/CD, add a Prettier check to your pipeline to catch unformatted code before it's merged. This tool is ideal for quick one-off formatting of CSS snippets, vendor stylesheets, or CSS extracted from browser DevTools.