How to minify CSS
- Paste your CSS into the box. It can be one rule or a whole stylesheet.
- Select Minify CSS. Nothing happens until you press the button.
- Check the line under Result, such as
93 characters → 55 characters (38 removed). - Select Copy result, or Clear to start again.
That count comes from a short stylesheet with a /* Main button */ comment, two-space indents and two rules. The output is .btn{color:#fff;padding:8px 16px}.btn:hover{color:#000}. The space inside 8px 16px stays, because the value needs it.
What the minifier removes and keeps
The tool deletes every /* */ comment, turns each run of spaces, tabs and line breaks into one space, then drops the spaces around { } : ; and ,. Last, it removes the semicolon right before each closing brace. These are real results from the tool.
| You paste | You get | Note |
|---|---|---|
| /* nav */ .nav { margin: 0 auto; } | .nav{margin:0 auto} | Comment, outer spaces and last semicolon gone |
| h1, h2 { color: red; } | h1,h2{color:red} | Space after the comma removed |
| .a { width: calc(100% - 20px); } | .a{width:calc(100% - 20px)} | Spaces around + and - kept, so calc() still works |
| @media (max-width: 600px) { .a { color: red; } } | @media (max-width:600px){.a{color:red}} | Media queries stay valid |
| ul > li + li { margin: 0; } | ul > li + li{margin:0} | Spaces around > and + are not removed |
| .a { color: #ffffff; margin: 0px; } | .a{color:#ffffff;margin:0px} | Colors and units are not shortened |
This is a whitespace and comment minifier. It does not shorten #ffffff to #fff, drop units from zero, merge duplicate rules or remove unused selectors.
Check these cases before you ship
The tool treats quoted text and selectors like the rest of the file. In most stylesheets this never matters. In these four cases it changes the result:
- Spaces inside quotes are squeezed.
content: "a b"becomescontent:"a b", andcontent: "Note: see"becomescontent:"Note:see". - Comment-like text inside quotes is deleted.
content: "/* x */"becomescontent:"". - A space before a colon in a selector is removed.
.card :first-childbecomes.card:first-child, which targets a different element. Write.card *:first-childinstead and the meaning is kept. - License comments that start with
/*!are removed like any other comment. Add the notice back if your license requires it.
How much does minifying CSS help?
Savings depend on how much whitespace and how many comments your file has. A heavily commented, indented stylesheet shrinks a lot. CSS that is already compact barely changes. The counter shows characters, which equals bytes for plain ASCII CSS.
Most web servers also compress CSS with gzip or Brotli before sending it. Compression already squeezes repeated spaces well, so the transfer saving is smaller than the counter suggests. Use both: minify the file, then let the server compress it. Page speed is only one small part of search ranking, so do not expect a ranking change from minifying alone.
Can minified CSS be un-minified?
Partly. The CSS Formatter can add line breaks and indentation back so the code is readable again. Removed comments are gone for good, and squeezed spaces inside quotes are not restored. Treat the minified copy as output and keep editing your original. If your CSS sits inside a style tag in a page, the HTML Minifier handles the surrounding markup.
Common Mistakes to Avoid
Editing the minified file directly
Solution:
Losing a required license notice
Solution:
Writing a descendant selector with a leading colon
Solution:

