Minified CSS is the same stylesheet with everything a browser ignores taken out. It is one of the first things page-speed tools like Lighthouse suggest, and it takes seconds to do. This guide explains what is removed, what you save, and the two cases where a simple minifier can change how your styles behave. To minify a stylesheet now, paste it into the free CSS Minifier.
What minification removes
Before:
/* Primary button */
.button {
color: #ffffff;
padding: 8px 16px;
border-radius: 6px;
}After:
.button{color:#ffffff;padding:8px 16px;border-radius:6px}The basic steps, which every minifier does:
- Remove comments.
- Remove line breaks and indentation.
- Remove spaces around
{ } : ; ,. - Remove the last semicolon in each rule, which CSS allows.
Spaces that matter stay. padding: 8px 16px keeps the space between the two values, and calc(100% - 2rem) keeps the spaces around the minus sign, which CSS requires.
Advanced minifiers used in build tools, such as cssnano and Lightning CSS, also:
- Shorten colours:
#ffffff→#fff,rgb(255,0,0)→red - Remove zero units:
0px→0 - Merge duplicate selectors and rules
- Combine longhand properties into shorthand
- Remove rules that can never apply
How much it saves
On a commented, indented stylesheet, the basic steps save roughly 15–35% of the raw size. Advanced minifiers add a few more percent.
Servers almost always send CSS compressed with gzip or Brotli, which already squeezes repeated whitespace very well. After compression, minification typically saves only a few more percent. That still matters on large stylesheets and on slow mobile connections, and it is free once it is part of your build — but compression and removing unused CSS are bigger wins.
Where minifying by hand is genuinely useful:
- Email templates, where `` blocks count toward Gmail's ~102 KB clipping limit
- WordPress Additional CSS, theme option boxes and page-builder custom CSS fields
- Critical CSS inlined into the page ``
- Small static sites with no build step
Two cases where a simple minifier changes meaning
1. A space before a colon in a selector
These two selectors are different:
.menu :hover /* any hovered element inside .menu */
.menu:hover /* .menu itself, when hovered */A minifier that removes spaces around every colon turns the first into the second. The fix is to make the descendant explicit before minifying — .menu *:hover — which means the same thing and survives minification. The same applies to :focus, :first-child and other pseudo-classes written after a space.
2. Text inside quotes
Simple minifiers do not know about strings, so in
.note::before { content: "Note: read this, please"; }the spaces after the colon and comma inside the quotes can disappear, giving “Note:read this,please”. Check any content values, font-family names in quotes and url("…") paths after minifying. Build-tool minifiers parse CSS properly and leave strings alone.
How to minify CSS
Quick, one-off: paste into the CSS Minifier, check the bytes saved, copy the result. Runs in your browser.
In a project: let your build do it on every deploy, so the source stays readable:
- Vite, Next.js and most modern frameworks minify CSS automatically in production builds.
- PostCSS with the
cssnanoplugin. - Lightning CSS, a fast standalone minifier and transformer.
Good habits
- Never edit the minified file. Keep a readable source, edit that, minify again.
- Keep a source map in projects, so browser dev tools point you to the original lines.
- Test after minifying — especially pseudo-class selectors and quoted strings.
- Turn on gzip or Brotli on your server; it gives the largest saving.
- Remove unused CSS before minifying. A 200 KB framework stylesheet of which you use 10% is the real problem. The CSS Usage Analyzer helps find unused rules.
Related
The page's markup can be minified too with the HTML Minifier — our guide to HTML minification covers what to check there.



