Skip to main content

CSS Minifier

Paste a stylesheet and get a smaller one back — same rules, same selectors, same values, less weight for the browser to download and parse. Handy before emailing a file, pasting styles into a CMS field with a size limit, or shipping a page without a build step.

Conservative on purpose: this minifier only removes what the CSS token rules prove is inert. It never rewrites values, never merges rules, and keeps the spaces that carry meaning — and it runs entirely in your browser, so proprietary code never leaves the device.

License banners (comments starting /*! ) are normally kept — they carry attribution. Turn this off to remove every comment.

Minified CSS

153 bytes → 102 bytes (−33.3%) · 1 comment removed

Embed this calculator on your website →

The formula

tokenize → drop comments → drop only provably inert whitespace

  • Removed: ordinary comments, and whitespace around braces, commas, and the insides of declarations — plus the final semicolon before a closing brace, which CSS itself treats as optional.
  • Kept, deliberately: the space before a colon (ul li :hover targets descendants — it is a selector, not sloppy typing), spaces around + and − inside calc() (the grammar requires them), string contents, and /*! license comments unless you switch them off.
  • Never done: no value shortening (0px stays 0px), no color rewriting, no rule merging or reordering. If the input is malformed — an unterminated string or comment — the tool refuses rather than guessing.

Worked example: .a { color: red; margin: 0px; } becomes .a{color:red;margin:0px}— 31 bytes down to 24, with 0px left as 0px on purpose.

How it works

Proven, not hopeful. The engine was tested against an independent CSS parser: the original and the minified output must parse to the identical token structure, and minifying the output again must change nothing (a fixed point). Both properties are in the engine's permanent test battery, alongside hand-written golden examples covering @media, keyframes, calc(), strings, and license comments.

Where the savings come from. In hand-written CSS, most of the win is comments and indentation — commonly 20–40% on formatted source. Already-minified files barely shrink, which is itself a useful check.

Examples

  • A landing page without a bundler — minify the one stylesheet before uploading it to a static host.
  • A CMS custom-CSS field — squeeze a theme override under the field's character limit without hand-editing.
  • An email attachment — send the readable original to colleagues; ship the minified twin to the server.

Frequently asked questions

Is my code uploaded to a server?

No. The minifier runs entirely in your browser — unplug the network after the page loads and it keeps working. Nothing you paste is sent, stored, or logged.

Can minifying break my stylesheet?

This tool only removes comments and whitespace the CSS token grammar proves inert, and it was verified against an independent parser to keep the exact token structure. It never rewrites values, merges rules, or touches string contents. The one structural change is dropping the optional last semicolon before a closing brace, which is pure syntax, not meaning.

Why keep spaces inside calc()?

Because CSS requires them: calc(100% - 10px) is valid, while calc(100%-10px) is parsed as a percentage followed by a negative dimension — a different, invalid expression. The spaces around + and − in calc-like functions are grammar, and this minifier keeps them.

Why did a /*! comment survive?

Comments starting with /*! are the convention for license and attribution banners, and most minifiers preserve them. Turn the “Keep license comments” switch off if you want every comment removed.

Should I minify CSS that a bundler already processed?

There is little left to gain — bundler output is already minified, and this tool will confirm it by barely shrinking. The bigger wins are hand-written, commented, generously indented stylesheets.