How to get an accurate result from the CSS Minifier
An accurate result from the CSS Minifier comes from two habits: pasting clean CSS in, and checking the output before you use it. The tool already applies four fixed rules, so most accuracy problems come from pasting the wrong thing, or from trusting the saved figure without looking at the output itself.
At a glance
Paste CSS, not a whole page
The tool expects CSS, and only CSS. Paste the contents of a style tag or a .css file, and leave the HTML tags out. If you paste a whole page, the tool will still remove spaces and semicolons, but the result is not a valid stylesheet. The quick check is to look at the first characters of the output: they should be a selector, such as .card{, not a tag, such as <style>.
Check the three numbers before you copy
Read all three lines after every paste: the original size, the minified size, and how many characters were saved. For the default sample they read 105, 68 and 37, with 35% smaller above. For a short button rule they read 45, 33 and 12, with 27% smaller. If the saved figure reads 0, the CSS was already minified: minifying the 68-byte sample gives back the same 68 bytes. If the minified size is larger than the original, something was pasted that is not CSS, and you should check the input.
Check strings and calculations by eye
Two things deserve a look before you copy. First, quoted strings: a file name with a space, such as "my photo.jpg", must keep its space, and the tool copies quoted strings untouched, so it will. Second, calculations: the spaces around the minus sign in calc(100% - 20px) must survive, and they do, 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. Read the output line once, and if those two are whole, the rest is almost certainly right.
Check the selectors
The space in a descendant selector, such as .card .title or .page h1, must survive, because it means a title inside a card, or a heading inside a page. The tool leaves it alone, because it only removes spaces around punctuation. If a heading loses its styling after minifying, check the selectors in the output first: a missing space there is the most likely cause, and it usually means the input was edited by hand before pasting, not that the tool removed it.
Worked check: the default sample
Paste the sample back in and confirm the numbers: 105 bytes in, 68 bytes out, 37 saved, 35% smaller. Then paste the 68-byte output back in and confirm the second pass: 68 bytes in, 68 bytes out, 0 saved. That pair of checks tells you the tool is working and that the output is already in its shortest form. Do the same check with your own CSS: paste it, copy the output, paste the output back in, and the saved figure should read 0.
The common mistake
People read only the big percentage and never look at the output. The percentage only tells you how much dead weight the original was carrying, not whether the output is correct. A stylesheet full of comments can show 35% smaller and still be wrong if the input was not CSS at all. Read the output line once, check the strings and the selectors, and only then copy it.
Frequently asked questions
How do I check my minified CSS is accurate?
Read the three numbers, then read the output line: quoted strings and descendant selectors such as .card .title must be whole.
What should the default sample show?
105 bytes in, 68 bytes out, 37 saved, which is 35% smaller.
What does a saved figure of 0 mean?
The CSS was already minified. Minifying the 68-byte sample gives back the same 68 bytes.
Does minifying damage calc()?
No. The spaces around the minus sign in calc(100% - 20px) survive.
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?
- CSS Minifier — the complete guide
- CSS Minifier for students — with examples
- CSS Minifier for homeowners and DIYers
Try the CSS Minifier — free, in your browser.