Skip to content

Minify CSS

Strip comments and whitespace and shorten values. And if the minifier cannot handle something in your file, it says so — instead of quietly handing back a stylesheet with rules missing.

  • Never stored
  • No queue, no waiting
  • No signup, no watermark
Minified

The minified CSS appears here.

How it works

1

Paste your CSS

Or drop the file in. Nothing is stored.

2

Read the result

You get the minified stylesheet and how much smaller it is — or an explanation of what could not be handled.

3

Copy or download

Ready to drop into your build.

Where the bytes actually go

Most of the saving is whitespace and comments, which in a hand-written stylesheet is a great deal — indentation, blank lines between rules, and the section headers that make a large file navigable are all pure overhead once it is served. Beyond that, values are shortened in ways that cannot change what they mean: a colour written as #ffffff becomes #fff, 0px becomes 0 because zero needs no unit, a leading zero in 0.5em goes, and margin: 10px 10px 10px 10px collapses to margin: 10px.

What is deliberately not done is the risky category. Merging rules with identical declarations, or reordering them, changes the cascade — and the cascade is the part of CSS where two rules of equal specificity are resolved by which came last. A minifier that reorders aggressively will produce a smaller file and, in a large stylesheet, a subtly different page. Duplicate declarations are frequently deliberate too, left in as fallbacks for older browsers that ignore the second one.

Nested rules and modern media range syntax are refused rather than minified, and the reason is worth stating because it is the opposite of what most tools do. The parser behind this predates both features, and when it meets something it does not understand it does not raise an error — it silently deletes it, so a nested block simply vanishes from the output and the page loses styling that nothing reported. Refusing the file is the honest answer. If your stylesheet uses native nesting or @media (400px <= width <= 700px), use one of the tools below.

As with markup, judge the result after compression. Stylesheets are served gzipped or brotli-compressed, and those algorithms already handle repeated whitespace extremely well — so a file that minifies by 30 per cent may only shrink 5 per cent on the wire. The saving is real and smaller than the headline number.

When you want something else

Lightning CSS is the right tool for modern stylesheets: it understands nesting, media ranges, colour functions and everything else added in the last few years, minifies harder than anything older, and will also transpile new syntax down for older browsers as it goes. esbuild --minify style.css is nearly as good and extremely fast. Both belong in a build step rather than a browser tab.

The far larger win is usually removing rules you are not using. A site built on a utility framework or a component library commonly ships stylesheets where most of the file is never matched by anything on the page — and PurgeCSS, or the framework's own build, will cut that by an order of magnitude. Minifying unused CSS makes unused CSS smaller; deleting it is the actual fix.

Frequently asked questions

Is my CSS stored anywhere?

No, and for source code that is the point. Nothing is stored and no server ever sees it. Pasting proprietary source into an online minifier that posts it somewhere is a disclosure, whatever the site says about retention — and it is exactly the sort of thing that is done in a hurry without thinking.

Why did it refuse my file?

Because minifying it would have lost rules. The minifier behind this page dates from 2022 and does not know about two things that are now ordinary CSS. Given native nesting — a rule written inside another rule, with or without "&" — it returns the outer rule and SILENTLY DROPS the nested one. Given a modern media range query such as @media (width >= 400px), it returns an empty stylesheet. Neither produces an error. We measured both on the exact version we ship, and decided that handing someone a stylesheet with styles missing is worse than declining, so those two cases are detected and refused. Rules are also counted before and after as a general check, in case there is a third case nobody has found yet.

How do I minify nested CSS then?

Compile the nesting away first. Every build tool that supports nesting — Sass, PostCSS, Lightning CSS, or your bundler — flattens it as part of building, and the flattened output minifies here without complaint. If you are writing nesting by hand and serving it directly, you are relying on a feature that is supported in current browsers but the minifier ecosystem has not entirely caught up with.

What does it actually do?

Removes comments and whitespace, shortens colours (#ffffff becomes #fff, #ff0000 becomes red), trims unnecessary units and semicolons, and merges what can safely be merged. It does not remove rules it thinks are unused — that needs to know your HTML, and guessing wrong deletes styles you need.

How much smaller will it get?

For hand-written CSS, usually 15–30%. Already-compiled output from a build tool is often nearly minimal and will barely move. Gzip on your server does more than minification does; the two compound.

Is it safe to minify a production stylesheet here?

Yes. Nothing is stored, and the two cases it cannot handle are refused rather than silently broken, so what comes back is either correct or an explanation of why it was declined.

Good to know: Nested rules and modern media range syntax are refused rather than minified. The minifier is built on a parser that predates both, and rather than erroring it silently deletes what it does not understand — a nested block simply vanishes from the output. Refusing the file is the honest answer until that parser catches up.

Put this tool on your website

Free for any blog, class page or help article. Paste one snippet and your visitors can use it right on your page.