Minify CSS for faster websites
CSS files block rendering: the browser waits for your stylesheet before it shows the page. The smaller the file, the sooner visitors see content. This CSS minifier removes everything the browser does not need and applies safe shortcuts to reduce the size further.
How to minify CSS
- Paste your stylesheet into the left box.
- Click Minify CSS.
- Copy the result or download it as
style.min.css.
What the CSS minifier does
- Removes comments, except those starting with
/*!, which usually hold licence notices. - Removes line breaks, indentation and spaces around
{ } : ; ,. - Removes the last semicolon in each rule.
- Shortens values:
0pxbecomes0,0.5becomes.5and#ffffffbecomes#fff. - Removes empty rules.
- Leaves text inside quotes unchanged.
Best practice
Keep your original, readable CSS for editing and publish only the minified copy. Most build tools and WordPress caching plugins can minify automatically, but this tool is handy for quick jobs, landing pages and email templates. Minify your markup too with the HTML minifier, or format data with the JSON formatter.
Example
Before:
/* Buttons */
.btn {
color: #ffffff;
padding: 0px 16px;
opacity: 0.8;
}
After:
.btn{color:#fff;padding:0 16px;opacity:.8}
Why CSS size matters
CSS is render-blocking: the browser waits for your stylesheets before it shows the page. Every kilobyte you remove from the critical CSS helps the page appear sooner, which improves First Contentful Paint and Largest Contentful Paint. Google PageSpeed Insights flags unminified CSS as an opportunity for exactly this reason.
Safe optimisations used
- Removing comments (licence comments starting with
/*!are kept) - Removing whitespace and line breaks
- Shortening colours:
#ffffff→#fff - Removing units from zero values:
0px→0 - Dropping leading zeros:
0.8→.8 - Removing the last semicolon and empty rules
Text inside quotes, such as content: "…" and font names, is never changed.
More ways to speed up CSS
- Remove unused CSS from large frameworks.
- Combine small stylesheets to reduce requests.
- Inline the critical above-the-fold CSS and load the rest later.
Minify your markup too with the HTML minifier.
Frequently asked questions
Will minifying break my CSS?
The minifier only applies safe changes and never alters text inside quotes. Still, test your site after switching to the minified file.
How much smaller will my CSS be?
Usually 15–30%, and more if your stylesheet has many comments.
Can I un-minify CSS later?
You can re-format it with a beautifier, but comments are gone for good. Always keep your original file.
Are licence comments kept?
Yes. Comments that start with /*! are kept, as is the convention for licences.
