CSS Minifier
Paste your stylesheet and get a compact version that behaves the same way. The minifier strips comments and spaces, drops the final semicolon in each block, shortens colours and zero values where that is safe, and tells you how many bytes you saved.
What you enter
- CSS to minify
- Keep /*! licence comments
What you get
- Original size
- Minified size
- Bytes saved
- Saved
How it works
- Paste your CSS into the box. It is processed in your browser and never uploaded.
- Choose whether comments that start with /*! (usually licence notices) should be kept.
- Read the before and after size and the percentage saved.
- Copy the minified CSS or download it as a .css file, and keep your readable original as the file you edit.
What gets removed and why it is safe
CSS ignores most white space. A browser reads 'a { color : red ; }' and 'a{color:red}' as the same rule, so spaces around braces, colons, semicolons and commas can go. The semicolon is a separator between declarations rather than a terminator, which is why the last one in a block is optional.
A few spaces are not decoration. A space between two selectors means 'inside', so '.menu li' and '.menu.li' are different. Inside calc(), the plus and minus operators must have spaces around them. A good minifier keeps exactly these and removes the rest, and that is the difference between a tool and a find-and-replace.
Numbers, units and colours
A length of zero is zero in any unit, so the unit is redundant and 0px can be written 0. The same is not true for times and angles in every context, and not true inside calc() or for the flex shorthand, where a bare 0 can change the meaning. This tool leaves those alone on purpose.
A colour written as six hexadecimal digits can be shortened to three when each pair repeats, so #ffcc00 becomes #fc0. A colour like #ff0001 has no short form and stays as it is. Eight digit colours with an alpha channel shorten the same way when all four pairs repeat.
Where minifying fits in a build
Minification is one of three common ways to shrink a stylesheet, along with removing unused rules and compressing the response on the server. They stack: a minified file compresses well, and a smaller file also parses a little faster. For a single small site, pasting the result of this tool into a production file is enough.
For a larger project, run a minifier as part of your build so the step cannot be forgotten, and serve the output with a long cache lifetime and a file name that changes when the content does. Then visitors download the stylesheet once and never again until you change it.
Tips
- Edit the readable source and minify as a last step. Minified CSS is hard to change by hand, so never overwrite your only copy.
- Keep licence comments that begin with /*!. Many open source licences require the notice to travel with the code, and this option keeps them.
- Minifying saves the most on hand-written, well-commented stylesheets. If your server already compresses text with gzip or Brotli, the extra saving is smaller but still worth having.
- Remove unused rules before you minify. No minifier can know which classes your pages use, and deleting dead CSS usually saves more than squeezing the spaces out of it.
Frequently asked questions
What does a CSS minifier do?
It rewrites a stylesheet into the shortest form that means the same thing. Comments, line breaks and spaces around punctuation go, the semicolon after the last declaration in a block goes, and numbers and colours are written in their shorter forms.
Which shortenings does this tool make?
A zero length loses its unit (0px becomes 0), a leading zero goes (0.5em becomes .5em), trailing zeros go (1.50px becomes 1.5px), and a six digit colour whose pairs repeat becomes three digits (#ff0000 becomes #f00). Strings, url() contents and custom properties are left exactly as written.
Can minifying break my CSS?
Not when it is done by a proper tokenizer, which is how this tool works. It keeps the spaces that matter, such as the ones around + and - inside calc(), between a media query keyword and its brackets, and after an escape like \31 0. Check your site once after switching to the minified file, as you would after any build step.
How much smaller will my file get?
It depends on how much white space and commenting you started with. Take 'a { color: #ff0000; margin: 0px; }', which is 34 characters; it becomes 'a{color:#f00;margin:0}', which is 22, a saving of about 35 percent. Real stylesheets usually save less because rules are more varied.
Is my CSS sent to a server?
No. The minifier runs as code in your browser, so your stylesheet stays on your device.
Related: CSS formatter, CSS shadow generator, CSS layout generator.
Start a 7-day free trial or see all free tools. On We.Inc you get a 7-day free trial, not a free plan: card needed, $0 today, cancel before it ends and you pay nothing. AI building is on paid plans from $20 a month.
More in Free Tools
- CSS Box Shadow Generator
- CSS Specificity Calculator
- CSS Text Shadow Generator
- CSS to Tailwind Converter, Both Directions
- CSS Tooltip Generator
- CSS Triangle Generator
- CSS Wave Generator
- CSV to HTML Table Converter
Product
Who It's For
- For Agencies
- For Freelancers
- For Hosting Providers
- For SaaS Platforms
- For Startups
- For Financial Services
- For Healthcare
Features
Resources
- Blog
- Help Center
- Free Business Tools
- Free UI Components
- Website Templates
- Template Collections
- Website Examples
- Guides
- Comparisons
- Alternatives
- Best Lists
- Reviews
- Pricing Guides
- Use Cases
- Glossary & Guides
- Integrations
- Developers
- Benchmark
- Windows App