The Magic Codex

CSS Minifier

Paste your stylesheet. Get a compact, production-ready version back — comments stripped, whitespace collapsed, required spaces kept.

Everything stays in your browser. Nothing is uploaded or stored.

How to minify CSS

Minification is the last step before a stylesheet ships: it removes everything humans need (comments, indentation, line breaks) and keeps everything browsers need. Paste, minify, and serve the small file.

  1. Paste your CSS into the box above.
  2. Hit Minify CSS. The stats show exactly how many bytes you saved.
  3. Copy or download the result and use it as your production stylesheet — keep the readable original for future edits.

What gets removed — and what is protected

Removed: comments, extra whitespace, the last semicolon inside each { … } block, spaces around { } : ; , and around the > + ~ combinators. Protected: quoted strings (so content: "/* not a comment */" survives), url(…) contents, and the insides of calc(), min(), max(), and clamp() — because calc(100% - 20px) breaks if its spaces are stripped.

What does a CSS minifier do?
It shrinks your stylesheet by removing comments, collapsing extra whitespace, and dropping unnecessary characters — turning human-readable CSS into a compact file that browsers download faster. Your styles behave exactly the same.
Is it safe? Will my styles still work?
Yes. The minifier only removes characters that never change meaning: comments, redundant whitespace, and the last semicolon in a block. Spaces that matter — like the one in margin: 0 auto or inside calc(100% - 20px) — are preserved.
Why does minifying matter for page speed?
Smaller stylesheets download faster, especially on slow mobile connections. Minified CSS also compresses better with gzip and Brotli, so your real-world savings are even bigger than the byte count shown.
What about calc() and other functions?
Expressions like calc(100% - 20px) require spaces around the minus sign, so the minifier treats calc(), min(), max(), and clamp() as protected zones and never touches the spacing inside them.
Can I minify invalid or broken CSS?
The tool does its best with whatever you paste — it works on text patterns, not a full parser, so it never crashes. But always check your site after pasting, since broken input can produce broken output.

More from the codex