DevKit

CSS Minifier

Strip comments and whitespace from CSS without breaking strings, URLs or calc().

Free No sign-up Runs in your browser
CSS input
Minified
0Before (bytes)
0After (bytes)
0%Saved

Comments are removed entirely. Whitespace inside quoted strings and calc() expressions is preserved, because it is significant there.

What minification can and cannot do

A CSS minifier removes characters that the parser ignores: comments, redundant whitespace, the last semicolon in a block, and spacing around { } : ; , > ~. It does not rename classes, merge rules or reorder declarations — that is optimisation, a different and riskier job.

The typical saving is 15–25% of the source, and much less after gzip: whitespace compresses extremely well, so a 100 KB stylesheet might drop to 22 KB minified and 6 KB gzipped versus 8 KB gzipped unminified. The real win is in parse time and transfer for the uncompressed case, not a dramatic reduction in what crosses the wire.

Where naive minifiers break CSS

Three constructs need care:

  • Strings — content: "a b" must keep its double space, and a string can contain /* or ;.
  • calc() — calc(100% - 32px) requires spaces around - and +. Stripping them produces invalid CSS that silently drops the declaration.
  • url() — an unquoted URL may contain characters that look like syntax.

This tool protects quoted strings before doing any whitespace surgery and deliberately leaves + and - alone.

Should you minify at build time instead?

Yes, for production. Minifying once in a build step (esbuild, Lightning CSS, cssnano, PostCSS) gives you caching, source maps and reproducibility. Use a tool like this page to inspect what a minifier did to a specific rule, or to compress a snippet you are pasting into an email template or a CMS field.

Beyond minification

If payload size is the goal, the bigger levers are: removing unused CSS (PurgeCSS, Tailwind's JIT), splitting critical CSS for above-the-fold content, and modern formats such as @layer + cascade layers to avoid specificity battles. Minification is the last 10%, not the first 90%.

Frequently asked questions

Does minifying CSS break my styles?
Not if strings, calc() and url() are preserved, which this tool handles. Still, always diff the visual result of a production build — semantic bugs come from rule ordering, not whitespace.
How much smaller will my file be?
Typically 15–25% before compression, less after gzip or Brotli. Heavily commented files save more; already-compact files save very little.
Can I minify SCSS or LESS?
No — they must be compiled first. Minifying source SCSS produces invalid CSS because nested selectors depend on indentation and braces that the preprocessor owns.
Why keep the last semicolon?
It is optional in CSS, so removing it is safe. Keeping it makes concatenated files more robust if a rule is appended later — a build-tool concern, not a browser one.

Related tools