CSS Minifier
Minify CSS code by removing whitespace and comments.
Last updated: August 2026
Was this tool helpful?
What minifying CSS does and does not do
A CSS minifier shrinks a stylesheet by removing everything the browser does not need to apply the rules: comments, line breaks, indentation, the spaces around colons and braces, and the final semicolon in a block. It does not change which rules exist or how they cascade. The rendered result is byte-for-byte identical in behavior, just delivered in fewer bytes.
Smaller files matter because CSS is render-blocking. The browser will not paint until it has parsed your stylesheet, so trimming kilobytes off a large file shaves real time off first paint, especially on slow mobile connections where every byte travels over the air.
A concrete before and after
/* Primary button */
.btn-primary {
background-color: #3366ff;
padding: 12px 24px;
border-radius: 8px;
}Minified, the same rule collapses to:
.btn-primary{background-color:#36f;padding:12px 24px;border-radius:8px}Notice the comment is gone, the whitespace is gone, the trailing semicolon is gone, and #3366ff was safely shortened to #36f because the hex pair repeats. Those are the only kinds of changes a good minifier makes, and none of them alter the visual output.
Questions worth answering
Will minifying break my selectors or specificity? No. Minification is a text transformation, not a rewrite of your logic. Selectors, media queries, and the order of declarations are preserved, so the cascade behaves exactly as before.
Should I keep an unminified copy? Yes. Minified CSS is hard to read and debug, so keep the readable source in version control and minify as a build step. Ship the small file, develop against the big one, and generate a source map if you need to trace rules in dev tools.
Does it merge duplicate rules? Plain minification only removes whitespace and comments. Heavier optimizers can merge or dedupe rules, but that is a separate, riskier transformation. If you only want safe size reduction, basic minification is the predictable choice.
Doing the same for scripts? See the JavaScript minifier, which follows the same philosophy of stripping bytes without changing behavior.