About the CSS Minifier
The CSS Minifier compresses a stylesheet by removing comments and every space that CSS does not need around braces, colons, semicolons, commas, and child selectors. Paste code or open a .css file, compare the original, minified and gzipped sizes, and download the result.
How it works
The minifier removes all /* ... */ comments and sets quoted strings aside so their contents are never changed. It then collapses every run of whitespace to a single space and deletes spaces around { } ; , and >.
Spaces around colons are removed only inside declaration blocks, such as color : red becoming color:red. In selectors, a space before a colon is meaningful ("a :hover" is not the same as "a:hover"), so it is kept. Finally, a semicolon right before a closing brace is dropped and the strings are restored. Values are not rewritten, so #ffffff stays as written.
How to use
- 1
Paste your CSS into the input box, or click Open file to load a .css file.
- 2
Review the minified CSS and the size cards.
- 3
Click Copy or Download to use the result.
Worked examples
Small stylesheet
Two rules with a comment.
Descendant pseudo-class selector
A selector targeting any hovered element inside a link.
The space before :hover is kept, because removing it would change the selector to mean "a hovered link".
Frequently asked questions
Will minifying CSS break my styles?+
For valid stylesheets, no. Strings are protected, and spaces that change meaning, such as the one in "a :hover", are kept.
How much does minifying CSS actually save?+
It depends on how the source is written. Heavily commented and indented stylesheets often shrink by 20 to 40 percent before server compression.
Does it shorten colors or remove duplicate rules?+
No. It only removes comments, whitespace, and final semicolons. The gzipped size card shows how much your server's compression saves on top.
Can I un-minify CSS later?+
Comments are gone for good, but the formatting can be restored with a code beautifier.