CSS Minifier / Beautifier
Minify CSS, or expand it back to readable rules.
About CSS Minifier / Beautifier
A CSS minifier strips comments and whitespace to shrink a stylesheet; the beautifier expands minified CSS into readable, indented rules, with sizes shown.
How to use
- Paste CSS or load a
.cssfile. The result updates as you type. - Choose Minify to compress, or Beautify to format with a 2- or 4-space indent.
- Read the byte sizes under the output: original, result, and the percentage saved when minifying.
- Copy the result or download it as
.min.cssor.css, named after the loaded file.
What it does
- Minify strips comments except those starting with
/*!, which are the licence comments bundlers keep. It collapses whitespace, removes spaces around{,},:,;,,and the>combinator, drops the last semicolon in each block and the space before!important. - Strings and
url()arguments are tokenised, so a;,}or extra space inside quotes or a data URI is never touched. The space in@media screen and (and the spaces around operators incalc()are kept, because removing them changes the meaning. - Beautify puts one declaration per line with a space after the colon, splits comma-separated selector lists one per line, indents nested blocks such as
@mediaand@supports, and leaves a blank line between rules. Comments are kept. - Neither mode rewrites values: colours are not shortened, units are not changed, and duplicate or empty rules are not removed. Invalid CSS is passed through with the same whitespace treatment rather than rejected.
Example
/* card */
.card, .panel {
margin: 0 auto;
color: rgba(0, 0, 0, 0.5) !important;
}
→ .card,.panel{margin:0 auto;color:rgba(0,0,0,0.5)!important}
Privacy
Minifying and formatting run in the browser. No request is made, and nothing is stored.
Frequently asked questions
- Does minifying CSS change how a page looks?
- No, when done correctly. Browsers ignore comments and most whitespace, so removing them leaves the same rules. The exceptions are whitespace that is syntactically significant, such as spaces in calc() or in media queries, which this tool keeps.
- How much smaller does CSS get when minified?
- Typically 15 to 30 percent for hand-written CSS, mostly from comments and indentation. The saving on top of gzip or Brotli compression is smaller, because compression already handles repeated whitespace well.
- Why keep comments that start with /*!?
- By convention a comment that starts with an exclamation mark holds licence or attribution text that must ship with the code. Minifiers such as cssnano and clean-css keep them, and so does this one.
- What is the difference between minifying and beautifying?
- Minifying removes everything a browser does not need, to make the file small for production. Beautifying does the reverse: it adds line breaks and indentation so a minified or cramped file is readable again. The two are inverse operations on whitespace only.