CSS Minifier
Paste a stylesheet and get a minified version in one click — comments and unneeded whitespace removed, strings left untouched. See exactly how many bytes you saved, then copy or download the result.
Runs in your browser — your code and data never leave this device
How do I minify CSS online for free?
Paste your stylesheet here: this free online CSS minifier strips comments and unneeded whitespace, drops the last semicolon of each rule, and shows the before and after sizes so you can see exactly how much smaller the file got. Quoted strings, calc() spacing and media queries are protected, so the minified CSS means exactly what the original meant.
Related tools
How to use the CSS Minifier
- Paste your CSS into the Input box on the left, or click Sample to load an example stylesheet.
- Click Minify CSS. Comments and unneeded whitespace are removed; strings, calc spacing and media queries are left intact.
- Check the size readout to see how many bytes were saved, then click Copy output or Download to save the minified file.
- Keep your original readable stylesheet for editing, and use the minified version on your live site.
For the full picture — what minification removes, and why the original file still matters — read our guide: How to Minify CSS.
What minifying actually removes
Minifying a stylesheet removes the parts a browser never needs: comments, line breaks, indentation and the spaces around braces, colons, semicolons and commas. A rule like .button { background: #2563eb; } becomes .button{background:#2563eb} — the same rule, fewer bytes. The final semicolon before a closing brace is dropped too, because the brace already ends the declaration.
What it does not touch matters just as much. Text inside quotes is protected, so a content: "hello world" string keeps its space. The spaces inside calc() are kept, because calc(100% - 20px) breaks without them. Media queries keep the space before their opening bracket, so @media (max-width: 600px) still parses. Minifying is a safe, mechanical shrink — it never renames a class, reorders a rule or changes a value.
How much smaller does CSS get?
A typical hand-written stylesheet shrinks by 20 to 40 percent when minified, depending on how generously it was commented and spaced. A 50 KB stylesheet often comes out near 30 KB. That sounds small in an age of fast connections, but stylesheets block rendering: a browser waits for the CSS before it paints the page, so every kilobyte saved is time saved on first paint, especially on slow mobile networks.
Minifying also stacks with compression. A server that serves gzip or Brotli will compress the minified file further, and the two savings add up rather than overlap. Minify first, then let the server compress — the combination is the standard way production CSS is shipped, and it is what build tools like cssnano and Lightning CSS do automatically.
Minify for production, keep the original for editing
Nobody edits a minified stylesheet. The normal workflow is to keep a readable source file, edit that, and generate the minified version when the site is published. If you paste a stylesheet here, keep your original file safe — this tool does not store a copy anywhere, and there is no way to recover the comments and formatting once they are stripped.
For large projects, a build step is the better long-term answer: tools like cssnano, Lightning CSS or your bundler minify automatically on every deploy, and can also generate source maps so browser developer tools still show the original file while debugging. Use this page for quick one-off jobs — a snippet for a CMS, a theme file, a stylesheet you inherited — and a build tool for anything you ship every day.
Source maps deserve a mention, because they solve the one real drawback of minifying. A source map is a small sidecar file that tells the browser how the minified output maps back to your original stylesheet, so when you inspect an element, developer tools show the rule as you wrote it — file name, line number and all — even though the browser downloaded the minified version. If you minify by hand, you give that up; if a build tool minifies for you, turn source maps on and you get both the small file and the readable debugging.
What minifying removes — and what it leaves alone
Minifying removes only what the browser does not need: comments, unneeded whitespace, and the last semicolon before a closing brace. Everything else stays — selectors, values and the order of the rules — so the stylesheet behaves identically, just smaller. The before and after sizes show the saving in bytes, and you can copy the result or download it as a file.
What it does not do is just as important: it never renames selectors, never merges rules and never shortens colour values, so the minified file is a safe drop-in replacement for the original. Minify a copy for production and keep the original for editing — minifying is one-way, and an unreadable single line is no way to work. Pair it with gzip compression on your server and the two savings stack.
Frequently asked questions
Will minifying break my CSS?
No, as long as the CSS is valid to begin with. This tool only removes comments and whitespace, and it protects quoted strings, calc spacing and media queries, so the minified output means exactly what the original meant.
Does this tool change my selectors or values?
No. It never renames classes, reorders rules, merges selectors or shortens colour values. It only removes comments, whitespace and the final semicolon before a closing brace.
How is minifying different from gzip compression?
Minifying shrinks the file itself by removing characters. Gzip compresses the file while it travels from the server to the browser. They work together: a minified file compresses even smaller, so production sites use both.
Can I minify CSS that uses variables and calc?
Yes. Custom properties, var references and calc expressions are left intact, including the spaces inside calc that the syntax requires.
Is my stylesheet uploaded anywhere?
No. This tool runs entirely in your browser using JavaScript. Your code is never uploaded, stored or sent anywhere — everything stays on this device.
How much smaller will my CSS get?
A typical hand-written stylesheet shrinks by 20 to 40 percent when minified, depending on how generously it was commented and spaced. The tool shows the exact before and after sizes for your file, so you see the real saving, not a guess.
Can I minify more than one stylesheet at once?
One at a time: paste a stylesheet, copy the minified result, then paste the next. Each run shows its own before and after sizes, so you can track the saving file by file.
Can I get my original CSS back after minifying?
No — minifying is one-way: the comments and formatting are removed, not hidden. Keep the original file for editing and minify a copy for production, so you always have a readable version to work from.