CSS Formatter and Minifier
Beautify or minify CSS, including nesting and custom properties, with unclosed blocks and strings pinpointed. Values are never rewritten.
CSS
Formatted
The result appears here. Strings, url(…) values and custom properties are kept exactly as written.
Runs in your browser — nothing you enter leaves this device.
About this tool
What it does
Minified CSS from a build, a CDN or a browser’s dev tools is one unreadable line. This tool formats it — one declaration per line, selectors split at commas, nested rules and @media blocks indented — or does the reverse and minifies your own CSS for production. It reads the stylesheet the way a browser does, so it never cuts a string, a comment, an escape or a url(…) in half, and it handles modern CSS: nesting with &, @layer, @container, and custom properties whose values contain braces. As it reads, it checks for the mistakes that silently break a stylesheet — a block that is never closed, a string that runs to the end of the line, a bracket that doesn’t match — and gives the line and column.
How to use it
- Paste CSS, or press “Try an example”.
- Choose Format or Minify.
- For formatting, choose 2 spaces, 4 spaces or tabs, whether each selector gets its own line, and whether to keep comments.
- If there is an error, the message gives the line and column of the opening brace, quote or bracket that was never closed.
- Copy the result. When minifying, the footer shows the size before and after.
Limits and your data
- Formatting and minifying only change whitespace and comments. The minifier does not shorten colours, merge rules or drop units — those rewrites save little after gzip and are where minifiers introduce visual bugs. Use a build tool such as Lightning CSS or cssnano if you want them.
- It checks structure, not meaning: an unknown property or an invalid value is formatted as written. Browser dev tools will tell you which declarations they ignore.
- Sass, Less and Stylus syntax (variables with $ or @, mixins, // comments) is not CSS and may be reported as an error.
- Custom property values (--name: …) are kept exactly as written, including their spacing, because var() reads them back as written.
- Input is limited to 5 MB.
- Everything runs in your browser. The stylesheet you paste is never uploaded or stored.
Questions
Can minifying break my CSS?
Not with this tool. It removes comments, line breaks and the spaces around commas and the >, + and ~ selector combinators, plus the last semicolon in each block. It keeps the space between descendant selectors (nav a), the spaces calc() needs around + and −, and every string exactly. The tests compare the browser’s own reading of the stylesheet before and after.
Why are /*! comments kept when minifying?
By convention, a comment starting with /*! is a licence or copyright notice that must stay with the code. Minifiers such as cssnano and esbuild keep them too.
Does it support CSS nesting?
Yes. Nested rules, including ones starting with & such as &:hover, are indented under their parent with a blank line before each, the same way as rules inside @media.
How much smaller will minified CSS be?
Usually 15–30% before compression, depending on how many comments and how much indentation the source had. Your server’s gzip or Brotli compression then makes both versions much smaller, and the difference between them shrinks.
Why does it say a block is never closed?
Every { needs a matching }. The error points at the { that is still open when the file ends — usually a rule just above a missing }, or a } that was deleted along with a declaration. Browsers treat everything after it as part of that rule, which is why styles further down the file stop working.