How CSS Minification Works (and What It Must Never Touch)

Most of a stylesheet is there for humans. A minifier removes the parts the browser does not need.

By Web Tools Centre Team · Published November 29, 2026

What gets removed

What must be left alone

This is why a good minifier reads the structure of the stylesheet instead of running a few find-and-replace rules over it.

How much it saves

Hand-written, well-commented CSS typically shrinks by 15 to 30%. Server compression (gzip or Brotli) then shrinks the file much further, and the two work together: minify first, then compress. Because CSS blocks the page from rendering until it has loaded, every kilobyte saved helps the first paint.

One-off or automatic

For a single file, paste it into the CSS Minifier. For a site you deploy regularly, add a minifier such as cssnano or Lightning CSS to your build so it happens on every release, and keep the readable source in version control.

Quick FAQ

Can minification break my CSS?

A careless minifier can, for example by removing spaces inside calc(). Test the minified file before deploying, and keep the original source.

Is minifying the same as compressing?

No. Minifying removes unneeded characters from the file itself. Compression such as gzip or Brotli encodes the file for transfer and is undone by the browser. Use both.

How do I read minified CSS?

Paste it into the CSS Beautifier to restore indentation and line breaks.