How to minify CSS
- Paste your stylesheet into the box above.
- The compressed version appears immediately below.
- Check the saving reported in bytes and as a percentage.
- Copy the result, or download it as a .min.css file.
- Keep your formatted source, never edit the minified version.
What gets removed
- All comments, including licence banners, check terms before shipping.
- Whitespace between selectors, declarations and values.
- The final semicolon before every closing brace.
- Spaces around colons, commas and combinators.
- Nothing else: selectors, shorthand and order are untouched.
- String contents are preserved exactly, spaces and semicolons included.
What CSS minification actually saves
A hand-written stylesheet is mostly whitespace and comments by character count. Indentation, blank lines between rules, spaces after colons, and the explanatory comments that make it maintainable all cost bytes that the browser discards immediately on parsing.
Removing them typically cuts 20 to 35 per cent from a formatted stylesheet, and considerably more from one with extensive documentation comments. Since CSS blocks rendering. The browser will not paint until the stylesheet is parsed, that saving arrives at the most expensive moment in a page load.
Why this minifier is conservative
Aggressive CSS minifiers do much more: merging duplicate selectors, combining shorthand properties, converting #ffffff to #fff, reordering declarations, dropping rules they judge unreachable. Those techniques save more and occasionally change rendering.
The reason is that CSS is order-dependent and specificity is subtle. A repeated selector later in a file is often a deliberate override. A longhand property written after a shorthand is often intentional. A rule that looks unreachable may be targeted by JavaScript at runtime. This tool does none of that, so the output is always safe to ship without a visual regression check.
What it does do
- Strips every comment, since browsers ignore them entirely.
- Collapses whitespace between tokens to nothing where nothing is needed.
- Removes the last semicolon in each block, which is optional in CSS.
- Removes spaces around colons, commas and the child, sibling and adjacent combinators.
- Keeps a single space where one separates two values, as in
margin: 0 auto.
That last point matters and is where naive minifiers break stylesheets. Removing the space in 0 auto produces 0auto, which is not a valid value at all.
Comments and licences
Every comment is removed, including the licence banner that open-source frameworks put at the top of their files. Many licences require that notice to be preserved in distributed copies, so check the terms before shipping a minified third-party stylesheet. The usual practice is to keep the banner separately and prepend it after minification.
Minification is not the whole story
Serving CSS with gzip or brotli compression saves far more than minification does, because whitespace is highly repetitive and compresses extremely well. Minifying on top of that still helps, but the marginal gain is smaller than the raw percentage suggests. The two together are what you want, not either alone.
Bigger wins usually come from removing rules nobody uses, which needs analysis rather than compression. Use the CSS formatter to make a stylesheet readable while you audit it, and the HTML minifier for the markup around it. Everything runs locally with nothing uploaded.
Where the remaining weight usually is
Once whitespace and comments are gone, a stylesheet that is still large is large because of what it contains rather than how it is written. Unused rules are the usual culprit. A framework brought in for three components ships styles for forty, and none of it can be removed by a minifier because a minifier cannot know what your markup uses.
Font declarations are the other common weight, particularly when several weights and styles are loaded for a family that appears twice on the page. Auditing both is manual work, but it is where the real reduction lives: removing an unused half of a framework saves more than every whitespace optimisation combined.