CSS Minifier
Remove comments and collapse whitespace from CSS in safe mode — strings, custom properties and selectors stay intact, with a size comparison.
Reviewed 17 November 2026 · Free · No account needed
How to use
- Paste your CSS.
- Read the minified output and the saved percentage.
- Copy the result into your production stylesheet.
Example
Input: /* comment */ .btn { color: #fff; padding: 8px; }
Output: .btn{color:#fff;padding:8px}
How it works
Comments and unnecessary whitespace are removed from the stylesheet and declarations are compacted, producing valid CSS that behaves identically to the original.
A single pass removes /* comments */, collapses whitespace runs, and drops spaces around { } : ; , > while keeping one space elsewhere — so calc(100% - 2rem) and custom properties stay valid. Quoted strings are copied verbatim, and a trailing semicolon before } is removed.
/* comment */ .btn { color: #fff; padding: 8px; } becomes .btn{color:#fff;padding:8px}.
Edge cases to know
- Safe mode only: no rule rewriting, colour conversion or declaration merging.
- Text inside quotes (content strings, font names) is never touched.
- It is not a parser-based optimiser — heavily scaffolded CSS minifies less.
Limits & compatibility
- Safe mode: no rule rewriting, colour conversion or declaration merging.
- The contents of quoted strings (content, fonts) are never touched.
- Not a parser-based optimizer — heavy scaffolding may minify less.
Privacy
Your CSS never leaves the browser. There is no server call, no storage and no logging of content.
Related tools
Questions about CSS Minifier
What exactly gets removed from my CSS?
Comments, runs of whitespace, and spaces around structural punctuation such as braces, colons, semicolons, commas and the > combinator — a trailing semicolon before a closing brace is dropped too. Quoted strings are copied verbatim, so content strings, font names and URLs survive byte-for-byte. The page's example collapses a commented rule to .btn{color:#fff;padding:8px}.
Will calc() and custom properties survive minification?
Yes, by design. Spaces around +, − and ~ are deliberately kept so expressions like calc(100% - 2rem) and custom property values stay valid; only spaces around { } : ; , > are removed. This safe-mode guarantee matters more than a few saved bytes — an invalid stylesheet saves nothing.
Does it merge duplicate rules or shorten colours?
No — safe mode does no rule rewriting, no colour conversion and no declaration merging. It is deliberately not a parser-based optimiser, so unusually heavy scaffolding may minify less aggressively than a full CSS engine would. What it never touches is meaning: selectors, values and strings pass through unchanged apart from whitespace.