Why minify CSS?
Every byte a browser downloads has a cost — in time, bandwidth, and perceived performance. CSS files are often full of whitespace, comments, and formatting that humans need but browsers ignore. Minification strips that out, producing the smallest valid CSS that renders identically.
A typical stylesheet shrinks 20–40% after minification. For large codebases, that is hundreds of kilobytes saved per page load — improving Core Web Vitals scores and reducing hosting bandwidth.
What minification removes
| Removed | Example |
|---|---|
| Comments | /* nav styles */ |
| Newlines & indentation | \n \t (whitespace) |
| Spaces around { } ; : | .class { color : red ; } |
| Trailing semicolons | color: red; } → color: red} |
| Extra spaces in values | margin: 10px 20px → margin:10px 20px |
Minify vs beautify — when to use each
Minify before deploying to production. Smaller files = faster page loads. Most build tools (Vite, Webpack, PostCSS) do this automatically, but this tool is useful for quick manual optimization or one-off files.
Beautify when you receive or inherit minified CSS and need to read or edit it. It restores indentation and line breaks, turning a single unreadable line back into structured, navigable code.
CSS file size benchmarks
| File | Raw | Minified | Saving |
|---|---|---|---|
| Bootstrap 5 | 232 KB | 197 KB | ~15% |
| Tailwind (full) | 3.7 MB | ~700 KB | ~81% |
| Foundation 6 | 195 KB | 155 KB | ~20% |
| Typical site | 50–200 KB | 30–130 KB | 20–40% |