CSS Minifier

Developer

Shrink a stylesheet without changing what it selects.

Minified CSS
/*! (c) 2026 Example — licence notice, kept */ .card .title{color:#abc;margin:0 .5em;width:calc(100% - 20px)}.card>.body{padding:8px}.card::after{content:"two spaces"}
72 bytes saved — 29.8% smaller
Before242 B
After170 B
Saved29.8%
What it did
Comments removed1
Licence comments kept1
Bytes before242
Bytes after170
Nothing is reordered or merged. Two rules with the same selector are left as two, and declarations keep their order — the cascade depends on it, and a minifier that reorders is rewriting your stylesheet rather than shrinking it.
Spaces inside calc, clamp, min and max were kept. They are REQUIRED there: calc(100% - 20px) is valid and calc(100%-20px) is not, because -20px would read as a signed length rather than a subtraction.
1 licence comment beginning /*! was kept. That form is the long-standing convention for a notice that must survive minification, and removing one from a stylesheet that carries a licence is the only deletion here with legal consequences.
Text inside quotes was left exactly as it is, spaces included. A minifier that squeezes whitespace everywhere changes what a content property actually renders.

How to use

What it's for

Make a stylesheet smaller so a web page loads faster, by removing the spaces, line breaks and comments that only people need — without changing how the page looks.

Before you start

Have the CSS to hand — the code that sets a web page's colours, sizes and layout — copied from a .css file or a style block. It is minified in your browser and nothing is sent anywhere.

  1. Paste the stylesheet

    Replace the sample in Stylesheet with your own CSS.

  2. Choose what to shorten

    All three boxes are ticked at the start, and that suits most people. Keep /*! licence comments keeps a copyright notice that begins /*!. Shorten hex colours writes #aabbcc as #abc, and Shorten zeros and decimals writes 0px as 0 and 0.5 as .5. Untick one only if something you use needs the longer form.

  3. Minify and copy

    Press Minify. The result is in the band at the top of the card — it also changes as you type — and Copy puts it on your clipboard. Keep your original file for editing, and use the minified copy on the live site.

  4. Check what it did

    What it did below counts the comments removed and kept, and the size before and after. Notes under it say what was left alone on purpose.

Reading the result

  • Minified CSS: the stylesheet with everything a browser does not need taken out, ready to copy.
  • Before and After: the size of your stylesheet and of the result, in bytes (B).
  • Saved: how much smaller the result is, as a percentage. The line above it gives the same saving in bytes.

If it goes wrong

  • A space survived, such as in .a .b or inside calc(): it is needed there. Removing it would change which parts of the page the rule applies to, or break the sum.
  • Saved is close to 0%: the stylesheet was probably minified already, so there is little left to take out.
  • It is built for CSS only. Don't run JavaScript through it — that needs a different kind of tool.

What this is

There are three places whitespace is significant in CSS, and each is a way a stylesheet gets broken.

A bare space is the descendant combinator. .a .b matches a .b inside an .a; .a.b matches an element with both classes. Removing that space changes which elements the rule hits.

Inside quotes, content: "a  b" renders two spaces on the page.

And in calc() the space is required: calc(100% - 20px) is valid and calc(100%-20px) is not, because -20px would read as a signed length rather than a subtraction.

Nothing is merged or reordered. The cascade depends on order.

Questions

Why is there no JavaScript minifier here?

Because it is a different order of problem. Minifying JavaScript needs a real parser — scope analysis, automatic semicolon insertion, telling a regular expression from a division — and getting it 95% right silently corrupts somebody’s script. CSS has no equivalent traps: the grammar is flat, whitespace is insignificant outside a few well-defined places, and every transformation here is local.

Why did the space between my selectors survive?

Because a bare space is the descendant combinator, and it means something. “.a .b” matches a .b inside an .a; “.a.b” matches an element carrying both classes. Collapsing that space changes which elements the rule applies to — it is the single most damaging thing a careless CSS minifier does. Spaces around >, + and ~ are removed, because those combinators are explicit.

Why are the spaces in calc() left alone?

Because they are required. calc(100% - 20px) is valid and calc(100%-20px) is not — without the space, -20px reads as a signed length rather than a subtraction, and the whole declaration is dropped by the browser. The same applies inside clamp, min and max.

Will it remove my licence header?

Not if it begins with /*! — that form is the long-standing convention for a comment that must survive minification, and every minifier honours it. It is the one deletion here with legal consequences, so it is kept by default and the page tells you when it kept one. Ordinary /* comments are removed.

Does it merge duplicate rules to save more?

No, deliberately. The cascade depends on order — two rules with the same selector are applied in sequence, and later declarations win. A minifier that merges or reorders is rewriting your stylesheet rather than shrinking it, and the extra saving is not worth the class of bug it introduces.

What about the text in my content property?

Left exactly as it is, spaces and all. content: "a b" renders two spaces, so squeezing whitespace inside a string changes what appears on the page. Hex colours inside strings are not shortened either, for the same reason.

The maths

Which spaces survive
.a .bkept — descendant
.a > .bremoved — explicit
calc(100% - 20px)kept — required
content: "a  b"kept — content
Why there is no JavaScript minifier

Minifying JavaScript needs a real parser — scope analysis, automatic semicolon insertion, telling a regex from a division. Getting that 95% right silently corrupts a script. CSS has no equivalent traps.

Keep going

Important

Runs entirely in your browser; nothing is transmitted. Nothing is reordered or merged — the cascade depends on order. Licence comments beginning with an exclamation mark are kept by default. Nothing you type here is sent to our servers — the calculation runs entirely in your browser.