People hesitate to minify a stylesheet they care about because minified output looks destructive: the readable file goes in, a dense block comes out, and it is natural to wonder what got thrown away in between. The honest answer for a careful minifier is a short list. Three things are removed, a specific set of things is protected, and a third set is left alone by deliberate choice, even though removing it would save more bytes.
This guide goes through all three lists for the free CSS Minifier on Ovatly, with the tool's own examples, so you can predict exactly what will happen to your file before you press the button.
Contents
- Quick answer
- Removed: comments
- Removed: redundant whitespace
- Removed: spaces around punctuation
- Kept: spaces that carry meaning
- Kept: strings and url(...) values, verbatim
- Kept by choice: names, colors and zero units
- How to see both lists on your own file, step by step
- Worked example: one rule, both lists at work
- Limitations and honest expectations
- Common mistakes
- FAQs
- Conclusion
Quick answer
The CSS Minifier removes comments, collapses whitespace and drops spaces around punctuation. It keeps the spaces that carry meaning: the gaps in descendant selectors such as .nav ul li, and the spaces inside calc(), min(), max() and clamp() where the CSS specification requires them. It copies strings and url(...) values, including data URIs, verbatim. And it deliberately does not rename classes, merge rules, remove unused CSS, shorten colors or strip units from zero values, because those are value rewrites that belong to a full optimizer in a build pipeline.
Removed: comments
Comments are the first and easiest removal. Everything written to explain the stylesheet to a human reader, section headers, notes about why a rule exists, reminders to a future editor, is invisible to a browser and pointless to send to one. On a mature stylesheet, comments can be a substantial share of the file, and deleting them changes nothing about how any page renders.
Removed: redundant whitespace
Whitespace is collapsed next. Indentation at the start of lines, blank lines between rules, and repeated spaces shrink to the minimum the syntax allows. A declaration that sat on its own indented line ends up packed against its neighbours. The selectors and declarations themselves are untouched; only the spacing that existed to line them up for human eyes goes away.
Removed: spaces around punctuation
The third removal is the spaces sitting next to punctuation: after an opening brace, around a colon, before a closing brace. The tool's own example shows all three removals in miniature. body { margin: 0; padding: 0; } becomes body{margin:0;padding:0}. Read the two side by side and the pattern is plain: every character that disappeared was either a comment character, a line break, indentation, or a space touching a brace, colon or semicolon.
Kept: spaces that carry meaning
Not every space is formatting. In a descendant selector, the spaces are the selector: .nav ul li targets list items inside a list inside the navigation element, and squeezing those gaps out would produce a different and invalid selector. So in the tool's example, .nav ul li { margin: 0 10px; } becomes .nav ul li{margin:0 10px}, with the selector spaces intact and even the space inside the value 0 10px preserved, because it separates two values.
Math functions get the same protection. calc(100% - 20px) is only valid with spaces around the minus sign, and the spaces inside min(), max() and clamp() are preserved wherever the CSS specification requires them. A minifier that stripped those would not make your file smaller and faster; it would make it broken.
Kept: strings and url(...) values, verbatim
Strings and url(...) values are data, not syntax, and they are copied exactly as written. That protection matters most for data URIs, where an image or font is encoded as a long string of characters inside the stylesheet. Change one character and the asset is corrupted, with no error message to tell you why the image stopped loading. The same care applies to ordinary quoted strings, whose contents are the page's business, not the minifier's.
Kept by choice: names, colors and zero units
The third list is the interesting one, because these are things a more aggressive tool would change and this one refuses to. It does not rename classes, so your selectors still match your HTML and your notes. It does not merge rules or remove unused CSS, so the structure you wrote is the structure that ships. It does not rewrite values either: #ffffff stays #ffffff instead of becoming #fff, and a zero value keeps its unit instead of losing it.
The reason is a deliberate boundary. This minifier only performs transformations that cannot change meaning. Value rewriting can change meaning in edge cases, so it is left to a full CSS optimizer in a build pipeline, such as Lightning CSS, which will give larger savings in exchange for doing that riskier work. Knowing this list exists is what lets you predict the tool's output: if a change would rewrite a value rather than remove formatting, the tool will not make it.
How to see both lists on your own file, step by step
- Open the CSS Minifier and paste your CSS into the input box.
- Press Minify CSS.
- Check the size report: characters in, characters out and the percentage saved. That total is the combined effect of the three removals.
- Spot-check the output for the kept list: find a descendant selector, a calc() expression and any url(...) value or data URI, and confirm each one survived character for character.
- Copy or download the minified CSS, and load the pages that use it once to confirm they render as before.
Worked example: one rule, both lists at work
Put the two example rules together and both lists are visible at once. The input:
body { margin: 0; padding: 0; }
.nav ul li { margin: 0 10px; }
The output:
body{margin:0;padding:0}.nav ul li{margin:0 10px}
Removed: the line breaks, the spaces after the opening braces and around the colons, the space before each closing brace. Kept: the two spaces inside .nav ul li that make it a descendant selector, and the space inside 0 10px that separates the two margin values. Nothing on the kept list was touched, and nothing on the removed list survived. That is the whole behaviour of the tool, and it scales from these two rules to a full stylesheet without surprises.
Limitations and honest expectations
Because the tool stops at meaning-safe changes, its savings are smaller than a build pipeline optimizer would achieve on the same file. It also expects plain CSS: SCSS or Less will not be understood correctly, since nested rules are not plain CSS, so compile first. And the kept lists are a promise about this tool's behaviour, not about every minifier; other tools make different choices, which is why checking a minifier's removals against its protections is worth doing before you trust it with a production file.
Common mistakes
- Assuming all minifiers behave alike. A tool that rewrites values can change edge-case behaviour. Check what a minifier keeps, not only what it removes.
- Fearing the selector spaces. If
.nav ul licame out with its spaces intact, that is the protection working, not a missed saving. - Editing values in the minified output. The minified file is generated output. Change the source and minify again.
- Pasting preprocessor code. SCSS nesting and Less variables are not plain CSS. Compile first, then minify.
- Expecting unused CSS removal. Deleting dead rules is a separate, riskier operation that this tool does not perform.
FAQs
What exactly does the minifier remove? Three things: comments, redundant whitespace, which it collapses to the minimum the syntax allows, and spaces around punctuation such as braces, colons and semicolons.
Why are some spaces kept instead of removed? Because they carry meaning. The spaces in a descendant selector like .nav ul li are the selector, and calc(100% - 20px) requires the spaces around its minus sign. Removing either would change what the CSS does.
Are strings and data URIs changed during minifying? No. Strings and url(...) values, including data URIs, are copied verbatim and never reshaped, because a single changed character inside a data URI corrupts the embedded asset.
Why does it not shorten colors or remove zero units? This tool sticks to transformations that cannot change meaning. Value rewriting, like turning #ffffff into #fff, is a job for a full CSS optimizer in your build pipeline.
Does it handle SCSS or Less? No. It expects plain CSS. Nested rules from preprocessors will not be understood correctly, so compile to CSS first.
Conclusion
A minifier you can trust is one whose behaviour you can list: three removals, a protected set of spaces and values, and a clear line it will not cross into value rewriting. The CSS Minifier works exactly that way, and its size report shows the result on your own file. To put the lists into practice on a page you actually ship, our companion guide on how to minify CSS for a faster landing page walks through the full workflow, and the rest of the Developer Tools guides cover the remaining tools in the category.