CSS Minifier — Shrink Style Sheets and See the Gzip Size
Strip comments and extra spaces from CSS stylesheets with byte savings stats.
419 → 384 bytes (8.4% smaller).
- The code is read token by token under CSS Syntax Level 3: quoted strings, unquoted url(…) values (data URIs with ; and # included), escapes, calc(), custom properties --x and var() values are never cut or changed.
- Minifying uses only certain equivalents: comments and spaces go, 0.50 becomes .5, #aabbcc becomes #abc and the last semicolon is dropped. Units such as 0px are kept because some properties need them.
When to use the CSS Compressor & Gzip Size Estimator
Smaller files load faster
Comments, spaces and line breaks go, the last semicolon in each block is dropped, 0.50 becomes .5 and the colour #aabbcc becomes #abc. The size before and after and the percentage saved show at once.
The size after gzip
Servers usually send CSS gzip-compressed. The gzip size is measured right in your browser with CompressionStream, so you know how many bytes really travel to visitors.
Only changes that are certainly safe
Units such as 0px are not dropped because some properties and calc() need them, and custom properties and var() contents are written as they are. The output is tested with esbuild: the original and the minified code give the same CSS.
Licence comments stay
Comments starting with /*! usually hold a library licence and must be kept. The default option keeps them, and you can turn it off when the licence lives elsewhere.
Frequently asked questions
What saving is typical?
Hand-written CSS usually shrinks 20–40% before gzip; CSS that is already minified hardly changes.
Are selectors and class names shortened?
No. Class names, IDs and selectors are written exactly as they were because your HTML and JavaScript use them; only spaces, comments and characters without meaning are removed.
Is the order of rules changed?
No. Order decides precedence in CSS, so rules and declarations keep their original order.
What about broken CSS?
Unclosed comments or strings and unmatched braces are marked with their line and column.
Is my code uploaded?
No. Minifying and the gzip measurement run in your browser.
Similar tools
- CSS Stylesheet Beautifier & PrettifierExpand compressed CSS rulesets into cleanly indented selector properties.
- HTML Beautifier & Indentation PrettifierRe-indent messy single-line HTML markup into readable nested element trees.
- HTML Whitespace & Comment MinifierCompress HTML documents by removing redundant whitespace & HTML comments.
- HTML to Clean GitHub Markdown ConverterConvert headings, links, bold/code tags & lists from HTML into clean Markdown.