Free CSS Minifier
Compress your stylesheet with a tokenizer-based minifier that keeps strings, url() values and license comments safe.
CSS Minifier: Compress your stylesheet with a tokenizer-based minifier that keeps strings, url() values and license comments safe. It is free, needs no sign-up and runs in your browser. How to use it: 1) paste your CSS or load the sample; 2) choose whether to keep /*! license */ comments; 3) click Minify, then copy or download the minified file. Instead of risky find and replace, the minifier parses your CSS into rules, at-rules and declarations, then writes the shortest safe version. Strings and url() values are copied exactly, so data URIs and content values never break.
How the CSS minifier works
Instead of risky find and replace, the minifier parses your CSS into rules, at-rules and declarations, then writes the shortest safe version. Strings and url() values are copied exactly, so data URIs and content values never break.
Optimisations applied
- Removes comments, except /*! license comments if you choose.
- Removes whitespace and line breaks, and spaces around selectors combinators and commas.
- Drops the last semicolon in each rule and removes empty rules.
- Shortens 0px, 0em and similar to 0, but never inside calc() or other functions where units are required.
- Shortens 0.5 to .5 and colours such as #aabbcc to #abc.
- Leaves custom property values alone apart from whitespace.
Formula
Savings = (original bytes minus minified bytes) divided by original bytes, times 100.
Limitations
Results depend on how your source is written. The minifier does not merge duplicate rules or reorder properties, because those changes can alter the cascade. It does not remove unused CSS, which needs your HTML to judge. Keep your readable source file and minify a copy as part of your publishing routine. Re-minify whenever you change the source, and clear any cache or CDN so visitors receive the new version.
About this tool
The CSS Minifier is built and maintained by the Hayyat Networks team, a digital marketing, SEO and web development agency working with businesses in New York and Lahore since 2016. It is part of our free Website Development Tools collection.
- Last reviewed
- CostFree, no sign-up
- Where it runsRuns in your browser
- Checking resultsThe method and a worked example are shown above, so you can verify every result.
- PrivacyIt runs entirely in your browser: what you type stays on your device and is never sent to us.
Spotted a problem or have an idea? Tell us and we will review it.
Link to this tool
Free to share in your blog, course notes or resource list. Copy the link below:
<a href="https://hayyatnetworks.com/free-tools/website-tools/css-minifier/">CSS Minifier</a> by Hayyat NetworksCSS Minifier FAQs
How much does minifying CSS save?
Most hand written stylesheets shrink by 15% to 35%. Files with many comments and generous indentation save more. Combined with gzip or Brotli on your server, transfer sizes drop much further, which helps First Contentful Paint on slower mobile connections.
Can minified CSS break my site?
A careful minifier should not. This tool keeps strings, url() values and calc() expressions intact and only shortens values where the result is equivalent. Always keep your original file and test your key pages after deploying a new minified stylesheet.
What is a /*! comment?
A comment that starts with /*! marks a license or copyright notice that should survive minification. Many open source libraries require you to keep it. This minifier keeps those comments by default and removes all others, so you stay compliant while still getting the smallest file.
Should I minify CSS if I use a WordPress caching plugin?
Many caching plugins already minify CSS automatically, so check their settings first to avoid doing it twice. This tool is useful for custom themes, landing pages, email templates and anywhere you serve a stylesheet without a build step or plugin.
Want our experts to implement these improvements?
Get professional support from Hayyat Networks. Request a free consultation.
