CSS Minifier & Beautifier

Paste CSS and minify for production, or beautify minified CSS with proper indentation.

Input: 218 chars | Output: 165 chars | Saved 53 chars (24.3%)

What minification does

Minifying CSS removes everything a browser does not need: comments, indentation, line breaks, the space after a colon, the final semicolon in a block. The result is functionally identical and considerably smaller.

Typical savings are 20-40% before compression. That is worth having, though as the section on gzip below explains, the benefit is smaller than the raw numbers suggest once transport compression is in play.

Key takeaways

  • Minification removes whitespace and comments without changing behavior.
  • Expect 20-40% size reduction before compression.
  • Gzip and Brotli already compress whitespace well, so the incremental gain is modest.
  • The bigger win is usually removing unused CSS, not compressing what you ship.
  • Always keep the readable source; minified CSS is a build output.

What gets removed

OperationBeforeAfterThis tool
Strip comments/* header styles */(removed)Yes
Remove whitespacecolor: red;color:red;Yes
Remove the last semicolon{color:red;}{color:red}Yes
Collapse line breaksMultiple linesOne lineYes
Shorten hex colors#FFFFFF#FFFNo
Trim zero units0px0No
Drop leading zeros0.5em.5emNo

More aggressive minifiers also rewrite values like the last three rows, merge duplicate selectors and reorder properties. This tool performs the safe transformations only: it never changes a value, keeps quoted strings exactly as written, keeps the spaces calc() needs around + and -, and keeps the space in selectors such as div :first-child.

Minification versus compression

This is the part most people misjudge. Gzip and Brotli are extremely good at compressing repetitive text, and whitespace is about as repetitive as text gets. So minification and compression overlap substantially.

StateTypical sizeSaving versus original
Original CSS100 KB-
Minified~70 KB30%
Original + gzip~20 KB80%
Minified + gzip~17 KB83%
Minified + Brotli~15 KB85%

Illustrative figures. Minification on top of gzip typically adds only a few percentage points - worth doing, but not the dramatic win the standalone numbers imply.

The bigger opportunity is usually unused CSS. Most sites ship a great deal of CSS that no page actually uses, particularly when a large framework is included wholesale. Removing unused rules routinely cuts a stylesheet by 80-90%, which dwarfs anything minification achieves. Tools that analyze your actual markup and strip what is never matched are where the real savings are.

Why CSS size matters for performance

  • CSS is render-blocking. The browser will not paint until it has parsed the stylesheets in the head, so every kilobyte delays first paint directly.
  • It delays Largest Contentful Paint, which is a Core Web Vital and a ranking factor.
  • Parse time scales with size, and matters disproportionately on low-end mobile devices.
  • Unused CSS still costs download, parse and memory even though it never matches anything.

A sensible CSS delivery strategy

  1. Remove unused CSS first - the largest single win by a wide margin.
  2. Minify as part of the build, never by hand.
  3. Enable Brotli on the server, falling back to gzip.
  4. Inline critical CSS for above-the-fold content and load the rest asynchronously.
  5. Split by route so a page loads only the CSS it needs.
  6. Set long cache headers with a content hash in the filename.
  7. Preload the main stylesheet so the browser discovers it immediately.

Keep the readable source

Minified CSS is a build artifact, not source code. Never edit it by hand and never commit it as the only copy. Keep your readable stylesheet in version control and generate the minified version during the build, so diffs stay reviewable and the next developer is not confronted with a single 70-kilobyte line.

If you only have a minified file - inherited from an old project, say - beautifying it restores readable formatting. It cannot restore the comments, which are gone permanently.

Everything runs in your browser. Your code and files are processed entirely on your own device - nothing is uploaded, logged or stored.

Frequently Asked Questions

What does minifying CSS do?

It removes everything the browser does not need - comments, indentation, line breaks, spaces around colons and braces, and the final semicolon in each block. The stylesheet behaves identically and is typically 20 to 40 percent smaller.

How much does minification actually save?

Around 20 to 40 percent of raw size, but only a few extra percentage points once gzip or Brotli compression is applied, because those algorithms already compress whitespace very effectively. It is worth doing, but it is not the dominant factor.

Is minified CSS slower to parse?

No, slightly faster if anything, since there is less text to read. The browser does not care about formatting - the parser treats whitespace as a separator and discards it either way.

Should I minify CSS by hand?

No. Minification belongs in your build process, run automatically on every deployment. Keep the readable source in version control so diffs stay reviewable, and treat the minified file as a generated artifact.

Can I recover the original CSS from a minified file?

You can restore the formatting by beautifying it, which makes it readable again. You cannot recover the comments - those are removed permanently, which is another reason to keep the original source.

What gives a bigger performance win than minification?

Removing unused CSS, by a wide margin. Most sites ship rules no page ever matches, especially when a full framework is included. Stripping what is genuinely unused routinely cuts a stylesheet by 80 to 90 percent.

Why does CSS size affect page speed so much?

Because CSS is render-blocking - the browser will not paint anything until it has parsed the stylesheets in the head. Every kilobyte directly delays first paint and Largest Contentful Paint, which is a Core Web Vital.

What is critical CSS?

The minimum set of rules needed to render what is visible without scrolling. Inlining it in the head lets the browser paint immediately while the full stylesheet loads asynchronously, which improves perceived speed considerably.

Related Calculators