CSS minifier
Paste a stylesheet to remove comments, line breaks and extra spaces. It is a safe minifier, not an optimizer: your rules, values and selectors are never rewritten, only the characters CSS ignores are removed.
Runs in your browser: nothing you enter is sent anywhere.
How to use it
- Paste your CSS in the left box.
- Decide whether
/*! ... */ license comments should stay.
- Copy the minified result. Below it you see how many bytes were saved.
What changes
| Before |
After |
a { color: red; } |
a{color:red} |
h1 , h2 { margin : 0 } |
h1,h2{margin :0} |
calc( 1px + 2px ) |
calc(1px + 2px) |
/* note */ |
removed |
url( a.png ) |
url(a.png) |
"A B" (string) |
unchanged |
Spaces around operators inside calc() are required by CSS, so they are kept.
Tips
Minify as a final build step and keep your readable source. Serve the result with gzip or Brotli, which together with minification gives the smallest download. If the tool reports an unterminated string, look for a missing quote or a /* without */ near the line shown.
Frequently asked questions
What does this minifier remove?
Comments, line breaks, indentation, spaces around braces, semicolons and commas, spaces after colons and parentheses, and the final semicolon before a closing brace. Strings and url() contents are copied exactly.
Why doesn't it shorten colours or merge rules?
That needs a CSS parser and a lot of care to avoid changing behaviour, and it saves much less than removing whitespace. This tool only removes characters that CSS ignores, so the result always behaves exactly like the input.
Is minified CSS always safe?
For whitespace and comment removal, yes. One thing is kept on purpose: a space before a colon, because a :hover and a:hover are different selectors. If your CSS is already invalid, minifying will not repair it.
What is a /*! comment?
A comment that starts with an exclamation mark is the usual way to mark a license or copyright notice that must survive minification. Keep the option ticked to preserve them, or untick it to strip every comment.
How much smaller will my CSS get?
It depends on how it was written. Heavily commented, nicely indented files often shrink by 20 to 40 percent before gzip. The saved size is shown under the result.