CSS Formatter & Minifier
Beautify messy CSS, or minify it for production. The minified stylesheet renders exactly like the original, which is checked on real frameworks.
Ctrl+Enter also works. Your CSS is processed in your browser and never sent to a server.
Smaller, and Rendering the Same
| Stylesheet | Original | Whitespace only | Optimised |
|---|---|---|---|
| Bootstrap 5.3.3 | 274 KB | 233 KB | 227 KB |
| Pico 2.0.6 | 90 KB | 81 KB | 79 KB |
| Bulma 1.0.2 | 745 KB | 678 KB | 668 KB |
Sizes before gzip. For each one, a real page was rendered in Chromium at 1280 px and 390 px, once with the original file and once with each output, and every computed style of every element, including ::before and ::after, had to match. Gzip or Brotli on your server will shrink all three columns much further; minifying still removes what compression cannot, like comments and overridden declarations.
Four Ways a Minifier Can Break a Site
Each of these came out of Lightning CSS, one of the best minifiers available, on its default settings while this tool was being built. None of them throws an error: the page simply looks different on some devices.
Media queries rewritten for new browsers only
@media (min-width: 768px) can be shortened to @media (width >= 768px). That range syntax only works from Safari 16.4, so on older iPhones and iPads the query silently stops applying and the layout falls back to mobile. This minifier keeps min-width.
Right-to-left layouts flipped
margin-inline-start means the left side in English and the right side in Arabic or Hebrew. Lowering it to margin-left for older browsers breaks every right-to-left page. Logical properties are left exactly as written.
Grid widths rounded
Lightning CSS keeps about six significant digits, so Bootstrap's 33.33333333% becomes 33.3333%: one column measured 423.984 px instead of 424 px, and 8.3333% + 91.6667% adds up to more than 100%. This minifier puts the original numbers back.
Licence comments dropped
Most libraries ship a /*! ... */ header that their licence asks you to keep. Comments starting with /*! survive every minify here, exactly once.
Beautify Without Changing Meaning
In CSS some whitespace is meaning. .nav a selects links inside .nav, and .nava selects nothing you wanted. calc(100% - 2rem)needs its spaces to be valid. So the formatter only adds or removes whitespace where the grammar ignores it: around braces and semicolons, before a declaration's colon, and between rules. Everywhere else a run of spaces becomes one space, which is how browsers read it anyway.
Delete every space and line break from your input and from the formatted output, and you get the same text. Comments stay where they were, and a declaration without its final semicolon keeps it missing. If you want to know whether the CSS itself is right, the CSS Validator checks every property and value, and the CSS error guides explain the fixes.