CSS Minifier

Strip comments and whitespace from CSS without changing what any rule does.

Paste a stylesheet or a fragment.

100 runs left today · sign up for more

About this tool

Removes comments and unnecessary whitespace from CSS, and reports how much smaller the result is.

**Deliberately conservative.** An aggressive minifier merges duplicate selectors, rewrites colours, reorders shorthand properties and drops rules it believes are unreachable. Each of those can change what the stylesheet does, and the resulting bugs are subtle enough to reach production — a hover state that stops working, a print rule that vanishes. This removes what is unambiguously removable and leaves everything else exactly as written.

Two things are protected specifically, because they are where naive minifiers break: **strings**, which can contain braces and semicolons that are not syntax, and **`data:` URLs**, whose base64 payload can look like anything at all.

Minification is worth roughly a third; compression on the server is worth three quarters and applies to the minified file too. Do both.

Common questions

How much does minifying save?

Usually 20 to 35 per cent on hand-written CSS, and less on output from a build tool that already strips comments. Compression on the server saves far more, and the two multiply rather than overlapping.

Why not shorten colours and merge rules?

Because those transformations can change behaviour. Merging selectors changes specificity ordering, and rewriting shorthand changes which sub-properties get reset. The saving is a couple of per cent and the failure mode is a bug nobody can find.

Are important comments preserved?

Yes. A comment beginning /*! is a licence comment by convention and is kept, because removing it can be a licence violation. Everything else goes.

Should I minify if I already use gzip?

Yes, though the gain is smaller than it looks — compression handles repeated whitespace well. Minifying first still helps, and it reduces parse time in the browser, which compression does nothing for.