CSS Minifier

Paste a stylesheet and this CSS minifier strips out comments and whitespace, shrinking the file while leaving every rule exactly as it was. A Beautify mode does the reverse when you need to read compressed CSS.

1Paste your CSS
2Press Minify (or Beautify)
3Copy or download the smaller file

Private by design: 100% in your browser — nothing is uploaded, no sign-up. This tool runs entirely on your device.

How to use this CSS minifier

Paste your stylesheet into the top box and press “Minify CSS”. The tool reads the code the way a browser does, removes the parts that only exist for human readers — comments, line breaks, indentation, and spaces around braces, colons and semicolons — and writes the result into the box below. Above the result you will see exactly how many characters went in, how many came out, and the percentage saved. Press “Beautify CSS” instead and the same engine runs in reverse, expanding compressed CSS back into one declaration per line so you can read it.

The savings are real but they come with one working rule: never edit the minified file. Keep your readable stylesheet as the source of truth, and treat minification as the last step before publishing, repeated every time the styles change. That way a smaller file never costs you a maintainable one.

Example: a navigation stylesheet, before and after

This small hand-written stylesheet with a comment, generous spacing and a media query:

/* Header styles */ .nav a, .nav span { color: #333; margin: 0 auto; padding: 10px 20px; } @media screen and (max-width: 600px) { .nav { display: none; } }

minifies to a single line:

.nav a,.nav span{color:#333;margin:0 auto;padding:10px 20px}@media screen and (max-width:600px){.nav{display:none}}

The file drops from 170 characters to 115 — 55 characters saved, 32.4% smaller — while every selector, property and value survives untouched. Notice what did not get removed: the space between 0 and auto, the spaces inside 10px 20px, and the space before the media query's bracket. Those spaces carry meaning in CSS, so they stay.

Where the bytes actually go

In a typical hand-written stylesheet, comments are the first saving: a file that documents itself well can carry 10–20% of its weight in explanations the browser will never read. Next comes indentation — two or four spaces at the start of every declaration line adds up across thousands of lines — followed by the spaces around punctuation and the blank lines between rules. The last small win is the semicolon before a closing brace, which CSS makes optional. None of these change how the page renders; they exist purely for the humans writing the code, which is exactly why they can be removed from the copy you ship.

The spaces a minifier must not touch

Aggressive minification has a few famous traps, and this tool is written to avoid them. Inside calc(), the spaces around + and - are required by the specification — remove them and the declaration becomes invalid. In media queries, a space must separate words like and from the bracketed condition that follows. Descendant selectors such as .nav a are nothing but a meaningful space. And quoted strings are copied character for character, even when they contain text that looks like a comment, because a string is data, not code. Knowing which spaces are decoration and which are load-bearing is the whole craft of a CSS minifier.

Where minification fits in a real workflow

On a project with a build step, minification usually happens automatically alongside bundling and compression, and a page like this one is a convenience rather than a necessity. Where it earns its keep is everywhere else: the hand-maintained site with no build tooling, the stylesheet embedded in a CMS theme, the quick fix you are making directly on a server, the snippet you are pasting into a page builder that charges its cost in page weight. In those places the choice is not between two minifiers but between minifying in ten seconds here and not minifying at all. One habit protects you in every setup: minify at publish time, from the readable source, and never in the other direction. The readable file is the asset; the minified file is packaging. Lose the packaging and you can regenerate it in seconds — lose the source and every future edit starts with the Beautify mode and a sigh.

Frequently asked questions

What does a CSS minifier actually remove?

It removes everything a browser does not need to understand the stylesheet: comments, newlines, indentation and spaces around punctuation such as braces, colons and semicolons. It also drops the final semicolon before a closing brace. Selectors, properties and values are never changed, renamed or reordered.

Will minified CSS behave exactly like the original?

Yes. Minification only removes characters that CSS treats as insignificant. This tool is careful with the places where spaces are required — inside calc() expressions, after words like “and” in media queries, and inside quoted strings, which are copied word for word. Even so, keep your original file as the source you edit, and minify a copy for production.

How much smaller will my stylesheet get?

It depends on how the file was written. Hand-written CSS with generous indentation and plenty of comments commonly shrinks by 10–30%. The sample on this page goes from 170 to 115 characters, a 32.4% saving. CSS that is already compact will shrink less, because there is less whitespace to remove.

What is the Beautify mode for?

Beautify does the opposite journey: it takes compressed CSS and expands it back into a readable layout with one declaration per line and consistent indentation. It is the tool you want when you inherit a minified stylesheet and need to read or edit it.

Is my CSS uploaded to a server?

No. The minifier runs in JavaScript inside your own browser. Your stylesheet never leaves your device, nothing is stored or logged, and the tool keeps working offline once the page has loaded.

Does it handle media queries, calc() and strings?

Yes. Media queries keep the spaces CSS requires (for example before a bracketed condition), calc() keeps the spaces around plus and minus signs that the specification demands, and quoted strings — including ones that contain comment-like text — are preserved exactly.

Should I edit the minified file afterwards?

No. Keep the readable version as your working file and treat the minified output as a publishing step, the same way you would not edit a compiled program. If you change the styles, edit the original and minify again — it takes a few seconds.

Why minify if servers already use gzip or Brotli?

Compression and minification stack. Gzip squeezes repeated patterns in whatever file you give it, and a minified file gives it less to squeeze, so the transferred size ends up smaller still. Minified files are also quicker for the browser to parse. The two techniques complement each other rather than compete.

Can I download the minified CSS?

Yes. The Download button saves the result as a styles.min.css file, and the Copy button puts it on your clipboard. Both act on the exact text shown in the result box, so what you see is what you ship.

Related tools