CSS Minifier

Paste your stylesheet: comments, extra whitespace and line breaks disappear in one click, with the percentage of bytes saved.

0Original bytes
0Minified bytes
0%Savings

Your code stays in your browser: nothing is stored or sent anywhere.

Why minify your CSS?

Every space, line break and comment in a stylesheet is a byte the browser downloads but never uses: on most hand-written CSS, minification trims 15–30% of the file size. A lighter file means a faster First Contentful Paint, a better Core Web Vitals score and less data burned by visitors on mobile connections. It is one of the simplest optimizations with zero downsides: to the browser, minified CSS behaves exactly like the original.

What this tool removes (and what it leaves alone)

It strips /* … */ comments, line breaks, indentation, whitespace around curly braces, colons, commas and combinators, and the trailing semicolon before }. Quoted strings and the contents of url(…) are protected and returned untouched: a content: "a b" rule or a path with spaces will not be altered. Selectors, properties and values stay exactly as you wrote them.

Server compression already does half the job

Almost every server sends CSS compressed with gzip or brotli, and those algorithms are excellent at exactly this kind of repetitive text: spaces, indentation and property names that recur a thousand times compress beautifully. On an already compressed stylesheet, minification gains far less than the drop in character count suggests.

The gain is still real for two reasons: the file takes less memory after decompression and the browser parses it faster. On a small site that means a few kilobytes, on a project with ten stylesheets the total starts to matter.

What a minifier must not touch

Inside strings and URLs, spaces are content, not formatting: removing a space inside content: "a b" changes what appears on the page. The same goes for the contents of embedded data: URIs, where one character less breaks the image.

The other delicate area is calculations and selectors: inside calc() the spaces around plus and minus are required by the syntax, and in the selector a > b the space can go while in a b it cannot, because there the space IS the descendant operator.

A minified file is not for editing

Minified CSS is a generated file, not a source: you edit the original and regenerate. Fixing the minified file directly leads to two diverging versions, and the first time somebody regenerates, the fix disappears without a trace.

For the same reason a minified file does not belong in version control if the project already has a build step: it is thousands of lines that all change on every build and make the history unreadable. If the site is hand-made instead, keeping both files is the only route, and then the rule above applies.

Nearby tools

For JSON there is Format and validate JSON, and if your CSS is unreadable because it is already minified, the opposite direction lives inside the same tool. To generate rules rather than clean them up, look at CSS gradient generator.