Skip to content
ZeroServer.tools

CSS Minifier

Strip comments and whitespace from CSS to reduce file size.

Drop a .css file or click to browseLoads it into the input below

Minification Settings

Compression Statistics

Original Size

290 B

Minified Size

212 B

Bytes Saved

78 B

Savings Ratio

26.9%

Minified (73%)Saved (27%)
-78 bytes (26.9%)
Output updated — 212 characters

Why minify CSS?

CSS minification reduces file size by removing developer-only content that browsers don't need: comments, leading/trailing whitespace, and newlines. The result is functionally identical but downloads and parses faster. This minifier strips block comments (/* … */), collapses all whitespace sequences to a single space, removes spaces around structural tokens ({}, :, ;, ,), and drops the trailing semicolon before a closing brace (permitted by the CSS spec). Typical savings range from 20–40% on real stylesheets. All processing runs locally in your browser.

Related tools: HTML Minifier · CSS Formatter · CSS Variable Extractor

Built and maintained by Meet Shah · Last updated

What this tool is used for

  • Checking how much a stylesheet shrinks before adding a build step.
  • Producing a compact stylesheet for an inline style block.
  • Stripping comments before sharing a stylesheet externally.
  • Checking whether a stylesheet's size is mostly rules or mostly comments.
  • Comparing two stylesheets on size with formatting removed.

Frequently Asked Questions

What can be removed safely?
Comments, whitespace between tokens, the last semicolon in a block, and leading zeros — `0.5em` becomes `.5em`. Colour values shorten where an equivalent exists, and `#ffffff` becomes `#fff`. None of it changes what the browser computes.
What must not be touched?
Whitespace inside strings, inside `url()` and inside `content` values, and the space in a descendant combinator — `a b` and `ab` are entirely different selectors. That last one is the mistake a regex-based minifier makes and a parser-based one does not.
How much does minifying save after gzip?
Far less than the raw figure suggests. Minification alone typically cuts 20–30%, but gzip already compresses repeated whitespace to almost nothing — the additional saving over compressed transfer is often in single digits.
Is removing unused CSS more valuable?
Usually much more. A framework where 90% of the rules are never matched is a far bigger win than whitespace, which is what tools like PurgeCSS target. The risk is dynamically generated class names, which static analysis cannot see.
Does minifying change the cascade?
It must not. Rule order and specificity have to be preserved exactly, which is why merging duplicate selectors is unsafe in general — two rules with the same selector separated by a third can only be merged if nothing between them matches the same elements.

Common errors and gotchas

  • Removing a comment that was load-bearing, such as a licence header or a build directive.
  • Losing a hack that depended on exact syntax, such as a deliberate parse error.
  • Expecting the savings a real build tool achieves, since whitespace is a small part of it.
  • Assuming the saving matters after gzip, which compresses whitespace extremely well.
  • Minifying source and committing it, so the readable version is lost.

Related Developer Utilities tools

Private & free — this tool runs entirely in your browser.

IndieKitShip your Next.js startup in days.affiliate