CSS Minifier
Remove comments and formatting whitespace from CSS.
Your result will appear here…
How to use CSS Minifier
- Paste your CSS.
- Select Minify.
- Review the result before you use it in production.
Example
Input / settings:
.card {
color: #333;
padding: 1rem;
}Output:
.card{color:#333;padding:1rem}The semicolon before the closing brace is dropped. Values such as #333 are left as written.
When to use
- Compact a small stylesheet or an embedded style block.
- Compare a handwritten rule with its compact form.
- Strip comments before you share a snippet.
Overview
CSS Minifier removes comments and whitespace from a stylesheet with a lightweight tokenizer, not a full CSS parser. It keeps comments that start with /*!, leaves strings and url() contents exactly as written, drops the last semicolon in each rule, and keeps a space only where CSS needs one. It does not shorten colors or values, merge rules or check that the CSS is valid.
Supported input
CSS text
Output details
minified CSS
Common mistakes
- Nothing is validated. An unclosed rule such as a { color: red is returned as a{color:red without an error, so minify only CSS that already works. An unclosed comment or string is reported.
- Values are not optimized. #FFF stays #FFF, 0.5em stays 0.5em, and the space before !important is kept: color:#FFF !important.
- Combinators keep one space: a > b + c becomes a >b +c. That is valid CSS but not as short as it could be.
- Repeated semicolons are kept. a { color: red; ; margin: 0 } gives a{color:red;;margin:0}, which is valid but not minimal.
- Only comments that start with /*! survive. Every other comment is removed, so keep required license notices in that form.
Practical tips
- Keep an unminified copy; minified CSS is hard to edit.
- Paste minified CSS into CSS Beautifier when you need to read it again.
Privacy and security
This tool runs entirely in your browser. Your input is never uploaded to our servers. Minification runs locally and only removes comments and whitespace; nothing is uploaded. Inside calc() and other parentheses the spaces around + and - are kept, because CSS requires them: calc(100% - 20px) stays as written.
References
Frequently asked questions
Does CSS Minifier shorten colors or merge rules?
No. It only removes comments and unneeded whitespace. Colors, units and rules are written back as they were.
Why was my license comment removed?
Only comments that begin with /*! are kept. Start the comment that way if it must stay in the output.
Is calc() safe to minify here?
Yes. Spaces around + and - inside parentheses are preserved, so calc(1px + 2px) keeps its meaning.