This free css minifier works instantly in your browser — no sign-up, no downloads. Answer: Paste CSS into the box below. csso strips comments and whitespace as you type, and the Restructure preset also merges rules, all in your browser.
csso 5.0.5 in your browser — whitespace strip or full restructure
Quick answer: minifying CSS deletes comments, whitespace, and redundant values, and can merge rules that repeat selectors. Percent saved = (input − output) ÷ input × 100. On our 772-byte sample stylesheet, csso with structure kept outputs 572 B (25.9% saved) and with restructuring 555 B (28.1% saved; 321 B gzipped). Custom properties and the media query survive every pass. Runs locally — your stylesheet is never uploaded.
| Preset | What it does | 772-B sample → | Saved |
|---|---|---|---|
| Keep structure | Deletes comments, whitespace and trailing semicolons; shortens colors, zero units and font-weight keywords | 572 B | 200 B (25.9%) |
| Restructure | …plus folds shorthands (24px 24px 24px 24px → 24px), merges rules that share declarations, drops overridden declarations | 555 B | 217 B (28.1%) |
| Restructured, gzipped | Transport compression on top | 321 B | vs 326 B for keep-structure |
Measured with csso 5.0.5 — the exact script this page loads — on the sample behind the Sample button. Stylesheets with more comments and repeated blocks shrink further; already-processed files shrink less.
This is csso 5.0.5 (MIT), a long-running CSS optimizer that also handles style minification inside SVGO. It loads from a CDN and runs entirely in your tab. It's not a regex cruncher: csso parses your stylesheet into an AST, rewrites it, and regenerates clean CSS, which is why the output is valid even when the input had quirks a naive tool would mangle.
Bytes saved = input − output; percent = (input − output) ÷ input × 100. The tool counts UTF-8 bytes, and when your browser supports CompressionStream it shows gzip sizes too — the honest number for anything served over HTTP, since text/html+css compresses well and raw savings overstate the network win.
Paste a stylesheet (the Sample button loads ours), pick a preset, and the output updates as you type. Keep structure is the choice when you want byte-predictable output that still mirrors your source order. Restructure squeezes further by merging rules with identical selectors and discarding declarations that later rules override. Copy or download when you're happy. One thing to watch: csso is forgiving and won't stop on broken CSS, so a rule it can't parse can silently disappear from the output. More on that below.
The Sample button loads a 772-byte product-card stylesheet: a :root block of custom properties, three rules, a hover state, and a @media (max-width: 640px) override. Keeping structure takes it to 572 bytes. The comment goes, "Helvetica Neue", Arial, sans-serif keeps its quotes, 0px 4px 12px becomes 0 4px 12px, and rgba(0, 0, 0, 0.10) tightens to rgba(0,0,0,.1). Restructuring reaches 555 bytes, because that pass also folds 24px 24px 24px 24px to 24px and trims 0 0 8px 0 to 0 0 8px. Gzipped, that's 321 bytes across the wire — on a 772-byte file the gzip win (391 → 321) is smaller than the minify win, which is exactly why both columns are shown: minify first, then let transport compression do its job.
Custom properties and media queries ride through untouched in both passes — they're declarations and at-rules like any other, and csso merges only what the spec guarantees equivalent.
Every row below is real output from csso 5.0.5, the same version this page loads. It's a handy way to see which tricks belong to which preset.
| Input | Keep structure | Restructure |
|---|---|---|
color: #ffffff | color:#fff | color:#fff |
background: rgba(0, 0, 0, 1) | background:#000 | background:#000 |
border-color: #FF0000 | border-color:red | border-color:red |
font-weight: bold | font-weight:700 | font-weight:700 |
padding: 0.50em | padding:.5em | padding:.5em |
margin: 0px 0px 0px 0px | margin:0 0 0 0 | margin:0 |
.btn { color: #fff } .link { color: #fff } | Two rules | .btn,.link{color:#fff} |
.c { color: red; color: blue } | .c{color:red;color:#00f} | .c{color:#00f} |
/*! Theme v2 | MIT */ | Kept | Kept |
--gap: 16px ; | --gap:16px | --gap:16px |
calc( 100% - 20px ) | calc(100% - 20px) | calc(100% - 20px) |
Two details stand out. Comments that start with /*! survive both passes, which is the convention for license headers, while ordinary comments are dropped. And csso leaves the values of custom properties alone apart from trimming spaces. In the sample, --surface: #ffffff stays six digits, because csso can't know where that variable will end up. The spaces around the minus sign inside calc() stay too, since CSS needs them.
Restructure is the default here and it's safe for most stylesheets. csso only merges or drops declarations when it can prove the result renders the same. In the table above, the doubled color loses the overridden red, and two rules with identical bodies become one selector list. It also understands !important: given .p{color:red!important}.p{color:blue}, it drops the blue declaration, since it could never win.
Choose Keep structure when you need the output to line up with your source. That helps if you're diffing minified files in version control, debugging a production stylesheet without a source map, or handing CSS to a tool that expects rules in their original order. You give up a few percent of savings. On our sample it's 572 bytes against 555.
csso is a forgiving parser. Browsers skip invalid CSS without complaint, and csso does the same. When it meets something it can't make sense of, it drops that part and keeps going rather than stopping with an error. We tested a stylesheet with a missing closing brace: .a { color: red; .b { margin: 0 } came out as just .a{color:red}, and the .b rule disappeared without a warning. A badly broken file can even come out empty.
So if the Saved figure looks too good to be true, or the output is suspiciously short, check your input for an unclosed brace or a stray semicolon. Running the stylesheet through a linter or your editor's CSS checker first catches these in seconds.
Yes, but expect a smaller gain on the wire than the raw number suggests. Compression is very good at squeezing out repeated whitespace, so some of what minification removes would have been compressed away anyway. On our sample, minifying cuts the raw file by 28.1% (772 to 555 bytes). Gzipped, the drop is 391 to 321 bytes, or 17.9%. That's still a real saving on a stylesheet that every page loads, and the browser has less text to parse once it arrives.
The best results come from doing both. Minify at build time or with this tool, then let your server or CDN compress the file. If you ship SVG icons with inline styles, the SVG Optimizer trims those too, and the JS minifier does the same job for your scripts. Our guide to minifying CSS covers build-tool setups.
It strips comments, whitespace, trailing semicolons, and safe-to-remove formatting, and can shorten colors, zero values, and font-weight keywords where equivalent. The result is functionally equivalent CSS that browsers render the same way. The Restructure pass goes further and merges rules, but only where csso can prove the cascade and specificity come out unchanged.
Typical stylesheets shrink 20–40%, more when the original is comment-heavy and generously formatted. Savings compound on large sites where CSS is fetched on every page load. Note that gzip already compresses whitespace well, so the post-gzip gain is smaller than the raw byte reduction.
An in-browser minifier using CSSO needs no Node toolchain, config, or command line — paste, click, copy. It is ideal for one-off files, quick patches, or environments where you cannot install build tools. For recurring production builds, a bundler pipeline is still the better long-term setup.
csso is a forgiving parser, like browsers. When it hits CSS it can't parse, such as a missing closing brace, it drops that part and carries on instead of showing an error. If the output looks too short, check your input for unclosed braces or stray characters.
Barely. It trims the spaces around custom property values but leaves the values themselves alone, so --surface: #ffffff stays six digits. Inside calc(), the spaces around plus and minus signs are kept because CSS requires them.