CSS Minifier — the complete guide
Minifying CSS is a small job with a surprising number of details: four rules, quoted strings that must survive, selectors whose spaces matter, and three live numbers to read. This guide covers every part of the CSS Minifier: what it removes, what it keeps, how it works, and the everyday uses, so you never have to guess what a setting does.
At a glance
What the tool removes
Four things go: comments between /* and */, extra whitespace such as line breaks and indent spaces, spaces around the punctuation marks { } : ; , > + ~ ( ) [ ], and the semicolon before each closing brace. None of those affects how the page looks, because the browser ignores comments and extra spaces, and a semicolon before a brace separates a declaration from nothing. Dropping that last semicolon saves one byte per block, so a stylesheet with four blocks saves 4 bytes on that rule alone.
What the tool keeps
Everything that affects the page stays: selector names, property names, values, quoted strings, and the space in a descendant selector such as .card .title. A file name with a space, such as "my photo.jpg", keeps its space, because the tool copies quoted strings untouched. A calculation keeps the spaces around its minus sign: calc(100% - 20px) survives whole, because a minus sign is not one of the punctuation marks the tool strips spaces around. A rule with both of those goes from 91 bytes to 75 bytes, saving 16 bytes, with the string and the calculation intact.
Reading the three numbers
Every change updates three figures: the original size, the minified size, and how many characters were saved, with a big percentage above them. For the default sample those read 105, 68 and 37, with 35% smaller above. The percentage is the share saved, so 37 saved out of 105 is 35%. A short button rule reads 45, 33 and 12, with 27% smaller. If your CSS is already tight, the percentage will be small, and that is a result in itself: it tells you there was little dead weight to remove.
The four rules, in order
First, comments come out. Second, each run of whitespace collapses to one space. Third, spaces around punctuation go. Fourth, the semicolon before each closing brace is dropped. Run on the default sample, those four rules turn 105 bytes into .card{margin:0;padding:10px;color:red}.card .title{font-weight:bold}, which is 68 bytes, saving 37 bytes. Run on a longer block of 186 bytes, they give 129 bytes, saving 57 bytes, or 31% smaller. The rules never change a value, rename a selector, or reorder a declaration: they only remove characters.
Copying and downloading the output
Press Copy minified CSS to put the output on your clipboard, then paste it into a style tag or a .css file. If you would rather have a file, press Download .css and the tool saves the minified CSS as minified.css. Either way, the output is exactly what the output box shows. Keep your readable original, with its comments and line breaks, and save the minified output under a different name, such as style.min.css, so you can edit the original later and minify a fresh copy.
The common mistake
People treat the saved figure as a score, and assume a bigger saving means a better result. It does not: the saving depends on how the CSS was written, not on how good it is. A stylesheet that was already written tightly saves little, while one full of comments and blank lines saves a lot, and both minify to valid CSS. The number that matters is the minified size itself, because that is the size of the file your visitors will download.
Frequently asked questions
What does the CSS Minifier remove?
Comments, extra whitespace, spaces around punctuation, and the semicolon before each closing brace.
What does the CSS Minifier keep?
Selector names, property names, values, quoted strings, and the space in a descendant selector such as .card .title.
How much does the default sample shrink?
From 105 bytes to 68 bytes, saving 37 bytes, which is 35% smaller.
How do I save the minified CSS?
Press Copy minified CSS to copy it, or Download .css to save it as minified.css.
Is my CSS uploaded anywhere?
No. Everything runs in your browser. Nothing is uploaded, stored or logged.
More guides on the CSS Minifier
- How to use the CSS Minifier — step by step
- CSS Minifier explained with worked examples
- CSS Minifier formula — how it actually works
- CSS Minifier for beginners — start here
- Common mistakes people make with the CSS Minifier
- CSS Minifier vs doing it by hand — which is faster?
- How to get an accurate result from the CSS Minifier
- CSS Minifier for students — with examples
- CSS Minifier for homeowners and DIYers
Try the CSS Minifier — free, in your browser.