CSS Minifier

Paste your CSS to remove comments and unnecessary whitespace, producing a compact single-line stylesheet. The tool shows how many bytes you save. Everything runs in your browser — your code is never uploaded.

Paste CSS, then press Minify CSS.

What minifying removes

Minifying CSS strips every character a browser does not need: comments, line breaks, indentation, and the spaces around braces, colons, semicolons and commas. The rules and values are untouched, so the page renders identically — it just downloads faster.

saved % = (original − minified) ÷ original × 100

Because CSS is whitespace-insensitive between tokens, removing it is safe. The minifier also drops the final semicolon before each closing brace, which the spec allows, shaving a few more bytes off large files.

Worked example

The rule on the left collapses to the compact form on the right:

Before: .card { color: #333; padding: 16px 20px; }
After: .card{color:#333;padding:16px 20px}
Saving: roughly a third of the bytes on typical hand-written CSS.

What it keeps safe

The minifier preserves strings, url() values and the meaningful single spaces inside multi-value properties like margin: 0 auto or font: 14px/1.5 sans-serif, where the space separates real values. It only collapses insignificant whitespace, so your styles behave exactly the same. Everything is processed locally, so proprietary stylesheets never leave your browser.

Tip: minifying scripts or markup too? Use the JS minifier and the HTML minifier.

Minification vs gzip vs brotli — they stack

A common question: "if my server already gzips CSS, why minify?" Because the two work on different things and combine. Minification removes characters the browser never needed; compression (gzip or brotli) then re-encodes what's left into fewer bytes over the wire. The browser decompresses on arrival, so you pay no runtime cost.

StageWhat it doesTypical effect on hand-written CSS
OriginalReadable source with comments and indentation100% (baseline)
MinifiedComments and insignificant whitespace removed~55–75% of original
Minified + gzipPlus general-purpose compression~15–25% of original
Minified + brotliBrotli (supported by all modern browsers over HTTPS) compresses CSS/JS noticeably better than gzip~12–20% of original

The numbers above are typical for hand-authored stylesheets; your mileage varies with how repetitive your CSS is. The takeaway: minify and enable brotli (or gzip as a fallback) at the server or CDN. Skipping minification before compression still leaves comments and whitespace in the decompressed file, so it isn't a substitute.

What this tool deliberately doesn't do

This is a safe, structural minifier — it removes whitespace and comments and trims the final semicolon before each }. It does not attempt the riskier optimisations that full build tools (cssnano, Lightning CSS) perform, because they need a real CSS parser to do safely:

  • Merging duplicate selectors and dropping rules overridden later — easy to get wrong when specificity or source order matters.
  • Shortening colours (#ffffff#fff, named colours → hex) and collapsing margin/padding shorthands.
  • Removing unused CSS — that requires scanning your HTML and JavaScript, which a paste-in tool can't see.

For a one-off file or a quick check this whitespace minifier is ideal. For a production pipeline, run a parser-based minifier as part of your build so those structural wins are applied safely with the markup in view.

Frequently asked questions

Does minifying change how my CSS works?

No. Only comments and insignificant whitespace are removed; every selector, property and value stays the same, so the rendered page is identical — it just loads faster.

How much smaller will my file be?

Hand-written, well-indented CSS typically shrinks 25–45%. Files that are already compact save less. The tool shows your exact percentage after minifying.

Are meaningful spaces preserved?

Yes. Spaces that separate real values — such as in margin: 0 auto or font shorthands — are kept. Only redundant whitespace around punctuation is collapsed.

Is my CSS uploaded?

No. The minifier runs in your browser with plain string processing. Nothing you paste is sent to a server.

MB
Mustafa Bilgic · Editor, Calcool
Removes comments and collapses insignificant whitespace per the CSS syntax rules; meaningful spaces in multi-value properties are preserved. Everything runs in your browser - nothing you enter is uploaded, logged or stored.

Related calculators