CSS Minifier

Shrink your stylesheets by stripping comments and unnecessary whitespace — with a live before/after size comparison.

Note: this is a simple minifier — it removes comments and whitespace but does not restructure or merge rules the way build-tool minifiers do.

—

How it works

Minification deletes every byte the browser does not need to understand your stylesheet. First, /* … */ comments are removed with a string-aware pass, so a comment-like sequence inside a quoted value — for example content: "/* hi */" — is left untouched. Then all runs of whitespace collapse to nothing wherever grammar allows: around braces, colons, semicolons, and combinators like > and +. Redundant trailing semicolons before a closing brace are dropped too. What remains is semantically identical CSS in far fewer bytes, which means faster downloads on every page load. Because this is a deliberately simple minifier, it will not merge duplicate selectors or rewrite values — for maximum compression, pair it with a build tool like Lightning CSS or cssnano.

How to use

  1. Paste your stylesheet into the “CSS to minify” box — sample code is pre-filled so you can see the effect immediately.
  2. The minified output updates live as you type: comments removed, whitespace collapsed, and redundant trailing semicolons dropped.
  3. Compare the before/after sizes shown to see exactly how many bytes you saved.
  4. Click “Copy minified CSS” and paste the result into your production stylesheet or build output.

Frequently asked questions

What exactly does the minifier remove?

CSS comments (/* … */), runs of unnecessary whitespace around braces, colons, semicolons, and combinators like > and +, and trailing semicolons before a closing brace. The pass is string-aware, so a comment-like sequence inside a quoted value — for example content: "/* hi */" — is left untouched.

Will minification break my CSS?

No. Every byte removed is one the browser does not need in order to parse your stylesheet, so the output is semantically identical to the input. Note this is a deliberately simple minifier: it will not merge duplicate selectors or rewrite values.

How much smaller will my CSS get?

Typically 20–40% for hand-written CSS with comments and generous formatting. Stylesheets that are already compact shrink less, since there is less redundancy to remove.

When should I use a build tool instead?

For maximum compression on large projects, pair this with Lightning CSS or cssnano, which also merge rules and rewrite values. This tool is for quick one-off jobs where setting up a build step is not worth it.