What Does a CSS Minifier Do?
A CSS minifier removes everything a browser doesn't need from a stylesheet: comments, line breaks, indentation, spaces around braces and colons, the last semicolon in each rule, and redundant characters in values. The result is functionally identical CSS that is often 20–40% smaller before compression. Smaller CSS downloads and parses faster, and because CSS is render-blocking (the browser waits for it before showing the page), trimming it directly improves page speed, Core Web Vitals like Largest Contentful Paint, and mobile experience.
The CSS beautifier does the reverse: it takes minified, compressed or messily written CSS and formats it with consistent indentation, one declaration per line and optional one selector per line, so it's easy to read, debug and edit.
How to Minify or Beautify CSS
- Paste your CSS or drop a .css file.
- Choose Minify or Beautify.
- Adjust options: keep licence comments, shorten colours and zeros, and remove empty rules (minify), or choose the indentation and selector layout (beautify).
- Check the stats: original size, new size, percentage saved and gzip size.
- Copy or download the result. Minified files are named
.min.css.
What Gets Optimised
| Optimisation | Before | After |
|---|---|---|
| Comments removed | /* Buttons */ | (removed; /*! kept) |
| Whitespace collapsed | color : red ; | color:red |
| Last semicolon dropped | {a:1;b:2;} | {a:1;b:2} |
| Hex colours shortened | #FFFFFF, #3366FF | #fff, #36f |
| Zero units removed | 0px, 0em | 0 |
| Leading zeros removed | 0.5em | .5em |
| Empty rules removed | .empty { } | (removed) |
Unsafe transformations are avoided. Strings and url() values are protected, spaces required inside calc() (100% - 2rem) are kept, and percentages such as 0% in keyframes and flex-basis aren't touched.
Minification, Gzip and Brotli
Web servers usually also compress CSS with gzip or Brotli during transfer. Compression and minification work together: minification removes content that compression can't (like comments), and the result then compresses further. The gzip figure shown estimates the real transfer size. For the best performance, also remove unused CSS (tools like PurgeCSS), inline the small "critical" CSS needed for the first screen, and cache your stylesheet with a long cache lifetime and versioned filenames.
Best Practices
- Keep your source readable and minify only the deployed copy. Never edit minified files by hand.
- Automate it in your build (Vite, webpack, Parcel, Lightning CSS or cssnano) for larger projects. Use this tool for quick jobs.
- Keep licence headers with
/*!comments, as many open-source licences require. - Test after minifying, especially with unusual hacks or very old browser prefixes.
Measuring the Impact
After minifying, check the difference in your browser's developer tools (Network tab), or with Lighthouse and PageSpeed Insights, which flag "Minify CSS" and "Reduce unused CSS" opportunities. For large sites, the biggest wins usually come from removing unused rules and splitting CSS per page. Minification is a quick, risk-free step that every production stylesheet should have.
Beautifying Third-Party CSS
When you need to understand or override styles from a theme, plugin or framework that only ships minified CSS, beautify it first. Readable rules make it easy to find the selector you need to override, and to spot its specificity. Remember to put your overrides in your own stylesheet rather than editing the vendor file, so updates don't overwrite your changes.
Example: Before and After
The sample stylesheet above shrinks by about a quarter. Comments disappear (except the licence), #FFFFFF becomes #fff, #3366FF becomes #36f, 0px becomes 0, 0.50em becomes .5em, the empty .empty rule is removed, and whitespace collapses. On a real site with tens of kilobytes of CSS, these savings add up to noticeably faster first page loads, especially on mobile connections.
Safe by Design
The minifier never changes the meaning of your stylesheet. Selectors, property names, values inside strings, URLs and calc() expressions are kept intact, and unbalanced braces are reported instead of producing broken output.
Frequently Asked Questions
Will minifying break my CSS?
No. It only removes characters that don't affect meaning, and protects strings, URLs and calc() expressions.
How much smaller will my CSS be?
Typically 15–40% before gzip, depending on how many comments and how much whitespace the original has.
Can I un-minify CSS?
Yes. Choose Beautify to reformat minified CSS. Removed comments can't be recovered, though.
Does it work with SCSS or LESS?
Plain nesting is formatted, but for preprocessor syntax (variables, mixins), compile to CSS first for reliable minification.
Is my CSS uploaded?
No. Everything runs in your browser.