🎭

CSS Minifier

Minify CSS by stripping whitespace, comments and redundant characters. Typically 20–40% smaller, with no change to how it renders.

✓ Free forever✓ No signup✓ 100% private — runs in your browser
CSS Minifier & Beautifier
Minify CSS for production or beautify it for readability. Shows compression percentage.
CSS Input
Output
Minified/beautified CSS appears here…

CSS is render-blocking: the browser will not paint until it has downloaded and parsed your stylesheets. That makes stylesheet size one of the most direct levers on how quickly a page appears, and minification is the cheapest way to pull it.

How to use the CSS Minifier

  1. Paste your CSS
  2. Click Minify to compress it, or Beautify to format it back
  3. Check the size reduction
  4. Copy or download the minified output

What minification removes

  • Comments, which exist purely for developers.
  • Indentation, newlines, and spaces around braces, colons and semicolons.
  • The final semicolon in each rule block, which is optional.
  • Redundant units on zero values — 0px becomes 0.

None of this changes what the browser does. Whitespace between tokens in CSS is insignificant, so minified and formatted stylesheets produce identical rendering.

Minification is not the whole story

Minifying a stylesheet full of rules you no longer use still ships all of them. On mature projects, unused CSS is usually a far bigger win than whitespace — sites that pull in a full framework for a handful of components routinely ship 90% dead rules.

The order that actually pays: remove unused rules, then minify, then make sure the server sends the file with gzip or brotli. Compression typically does more than minification alone, and the two stack.

Keep your source formatted and minify as a build step. Minified CSS is unmaintainable by hand, and committing it destroys diffs.

What safely compresses, and what a minifier must leave alone

A CSS minifier is working inside a strict constraint: the rendered result must be identical. That rules out several transformations that look obviously safe.

Safe and always applied: removing comments, collapsing whitespace between tokens, dropping the final semicolon in a block, trimming leading zeros so 0.5em becomes .5em, shortening hex colours where #ffffff can become #fff, and removing units from a zero value.

Not safe, and correctly left alone: reordering declarations within a rule, because later declarations override earlier ones and duplicates are sometimes a deliberate fallback for older browsers. Merging rules with identical selectors, because the position in the cascade changes. Removing a declaration that appears unused, because a minifier cannot see your HTML — and certainly cannot see markup your JavaScript generates at runtime.

That last point is the important one. Minification reduces bytes; it does not remove dead CSS. Finding unused rules requires analysing your actual pages, and doing it automatically is risky for exactly the reason above.

Where the real CSS savings are

Minification typically removes 15–25% of a stylesheet, and that is usually the smallest win available.

Unused rules are the big one. A site using a general-purpose framework commonly ships 90% CSS it never applies. Tooling that scans your markup and strips what is unreachable routinely cuts a 200 KB stylesheet to under 20 KB — an order of magnitude beyond what whitespace removal can do. It needs care with class names your JavaScript constructs at runtime, which is why such tools accept a safelist.

Compression is free and automatic. Gzip or Brotli on a text file typically achieves 70–80%, and Brotli beats gzip by a further 15% or so on CSS.

Splitting critical CSS changes perceived speed rather than size: inline the rules needed for the visible part of the page and load the rest asynchronously, so rendering is not blocked.

The sensible order is to remove what is unused, then minify, then let the server compress. Each step operates on the output of the last, and skipping the first leaves most of the saving on the table.

Where minification fits in a build

Minifying by hand is fine for a one-off. For anything maintained, it belongs in the build so it cannot be forgotten.

The conventional order is author, then process, then minify, then compress. Authoring happens in whatever you prefer — plain CSS, Sass, or a utility framework. Processing covers autoprefixing and any transforms. Minification comes last among the build steps, operating on the final assembled output rather than on each file, so it can shorten across the whole stylesheet. Compression is the server's job and needs no configuration beyond being switched on.

Two practices make this reliable. Generate source maps, so the browser shows you the authored CSS while serving the minified file — debugging minified styles without them is unnecessarily painful. And fingerprint the filename, as style.a7f3c2.css, so you can set a long cache lifetime and still have changes picked up immediately.

Keep the unminified file out of production rather than shipping both. Serving style.css alongside style.min.css invites something to reference the wrong one.

Frequently asked questions

Does minifying change how my CSS renders?

No. Only insignificant whitespace, comments and redundant characters are removed. The rules, selectors, specificity and cascade order are all unchanged.

Can I reverse it?

Formatting restores readable indentation, but comments are gone permanently — they are discarded, not hidden. Always keep your formatted source.

How much smaller will my CSS get?

Typically 20–40%, depending on how heavily commented and indented the source is. Heavily documented stylesheets save most.

Should I minify if my server uses gzip?

Yes — they stack. Gzip handles repetition well, but minification removes content entirely rather than compressing it, so the combined result beats either alone.