~/frontend-tools/css-minifier
CSS Minifier
Shrink a stylesheet for production. The minifier removes comments and unnecessary whitespace, drops the final semicolon in each block and shortens colours like #ffffff to #fff, while leaving strings, URLs and /*! licence */ comments untouched. You see exactly how many bytes you saved.
Using the CSS Minifier
What minifying does
Browsers ignore comments, indentation and most whitespace, but every character still has to be downloaded. Minifying removes them so the file is smaller and arrives faster. On a typical hand-written stylesheet the saving is 20 to 40 percent before compression.
What it keeps safe
The minifier works on CSS tokens, not blind text replacement, so content inside strings and url() stays exactly as written. Comments that start with /*!, the convention for licence notices, are kept. Spaces that matter, such as inside calc(100% - 2rem), are preserved.
Minify and compress
Servers usually compress files with gzip or Brotli as well. Compression and minification work together: minify first, then let the server compress. The saving shown here is before compression.
Keep the original
Always edit the readable version and minify a copy for production. If you need to read a minified file later, the CSS formatter will expand it again.
Minifying in a build pipeline
For a project you update often, add minification to your build instead of doing it by hand: most bundlers and frameworks minify CSS automatically in production mode. This tool is ideal for one-off files, theme editors, email templates and quick checks of how much a stylesheet can shrink.
How much smaller does minified CSS get?
It depends on how much space and how many comments the original has. Hand-written, well-commented stylesheets often shrink noticeably, while CSS that was already compact changes little. The tool shows the exact byte counts before and after, so you can see the saving for your own file.
Worked example: a component stylesheet
A rule written across several lines with indentation and a comment, such as a card style, becomes one line with the comment, line breaks and last semicolon removed and #ffffff shortened to #fff. The browser reads both versions in exactly the same way.
Frequently asked questions
Can minifying break my CSS?
It should not: the changes are safe ones. Always test the result, especially with unusual hacks or invalid CSS.
Does it merge duplicate rules?
No. It does not restructure rules, which keeps the output predictable.
Is my stylesheet uploaded?
No. Everything happens in your browser.
Should I minify CSS that I edit by hand?
Keep editing the readable version and minify a copy for the live site. Minified CSS is hard to read and change, so treat it as an output, not a source file.
Does minifying help page speed?
Smaller files download faster, which matters most on slow mobile connections. Server compression such as gzip or Brotli shrinks text further, and the two work well together.