Minifying CSS removes what the browser doesn't need: comments, line breaks, indentation and the last semicolon in each rule. Everyone says to do it. But browsers almost never download raw CSS; servers compress it with gzip or Brotli first, and compression already squeezes out repeated whitespace. So how much does minifying actually save?
I measured two well-known stylesheets on November 1, 2026, before and after minifying, raw and compressed (gzip level 9, Brotli quality 11):
| File | Raw | Gzip | Brotli |
|---|---|---|---|
| normalize.css 8.0.1, original | 6,138 B | 1,737 | 1,398 |
| normalize.css, minified | 1,852 (-69.8%) | 780 (-55.1%) | 606 (-56.7%) |
| bootstrap.css 5.3.3, original | 281,046 B | 32,865 | 24,501 |
| bootstrap.css, minified | 233,341 (-17.0%) | 30,743 (-6.5%) | 22,853 (-6.7%) |
Why the results are so different
normalize.css is mostly explanatory comments, and comments are text compression still has to send, so stripping them saves a lot even after gzip. Bootstrap's source is generated, tidy code with few comments, so after Brotli the saving is about 1.6 KB. For reference, Bootstrap's own bootstrap.min.css is 232,803 bytes raw and 22,709 with Brotli, within about 150 compressed bytes of the output above. I compared both outputs rule by rule: all 57 declarations in normalize.css and all 5,541 in Bootstrap kept the same meaning.
Practical rule: minify and compress. Minifying pays off most on commented, hand-written stylesheets: WordPress child themes, email templates, one-off landing pages.
Safe vs. "clever" minification
Safe changes can't alter rendering: removing comments (keep /*! license */ ones), whitespace between tokens, the final ; before }, and extra zero decimals (0.0px to 0). Rewriting values (#FFFFFF to #fff, bold to 700) saves a few more bytes but is where minifier bugs live. Things a minifier must leave alone:
- spaces around
-and+insidecalc(100% - 20px)(without them the rule is invalid) - spaces in media queries (
@media (min-width: 600px) and (max-width: 900px)) - quoted strings, including
content: " a /* not a comment */ "and font names like"Open Sans"
Two typing habits also break some minifiers: ! important with a space, and a missing } that silently swallows the next rule. Check your source for both before minifying.
What minifying won't do
It won't remove unused CSS. If most of a framework's rules never match your markup, you need a purge step (PurgeCSS, Tailwind's content scanning, or Chrome DevTools' Coverage tab to find them). That usually saves far more than minifying.
Doing it
In a build, Vite, webpack and most frameworks already minify CSS. For a one-off file I use a free online CSS minifier on a small tools site I help run; it shows the before/after size so you can see whether it's worth it. The full guide, with the step-by-step and more test cases, is here.
Comments
Join the discussionNo comments yet. Be the first to comment.