Skip to content
CSS

CSS Minifier/Beautifier

Beautify or minify CSS with size savings.

Original
189 B
Result
112 B
Reduction
−40.7%
.card{display:flex;padding:16px;border-radius:12px;background:#fff}@media (min-width:600px){.card{padding:24px}}

This tool prioritises reporting failures over returning a silently broken result. It deliberately skips optimisations that could change behaviour, such as removing units from zero values or reordering properties. License comments (/*! ... */) survive minification. Everything runs entirely in your browser; nothing is sent externally.

About CSS Minifier/Beautifier

A CSS minifier/beautifier reformats stylesheets for readability (beautify) or strips whitespace and comments to shrink file size (minify). Many simple implementations do this with blind regex find-and-replace, which can corrupt content inside string literals (e.g. content: "a;b") or inside url() — including query strings and data URIs like url(data:image/svg+xml;base64,...). toco.tools's CSS minifier instead tokenizes the source with a real character scanner that understands string literals, comments, and url() before building a structural tree of selectors and declarations, so those hazards are handled correctly. Bang comments (/*! ... */), typically used for license headers, always survive minification verbatim. Quoted attribute-selector values (a[title="x y"]) and nested at-rules — @media, @supports, @font-face, @keyframes, @import, @charset — are all supported. The minifier only applies optimisations that are provably safe: stripping comments, collapsing whitespace, removing whitespace around structural characters, dropping the trailing semicolon before a closing brace, removing empty rules, shortening #aabbcc-style hex colors to #abc, and dropping the leading zero in decimals like 0.5 → .5. It deliberately does not strip units from zero values (unsafe for properties like flex-basis) or reorder/merge properties (which can change cascade behaviour) — this tool prioritises never breaking your stylesheet over squeezing out the last few bytes. Malformed CSS produces a clear error rather than a silently broken result. Everything runs entirely in your browser; nothing is ever sent anywhere.

How to use

  1. Paste your CSS
  2. Choose Minify or Beautify
  3. Check the ratio, copy the output

FAQ

How is this different from other CSS minifiers?

It uses a real tokenizer that understands strings, comments, and url() instead of blind regex replacement, so semicolons inside strings (content: "a;b") and data URIs like url(data:image/svg+xml;base64,...) are never corrupted.

Will my license comment be stripped?

Bang comments starting with /*! are preserved verbatim after minification. Ordinary comments (/* ... */) are removed.

Does it strip units from zero values or reorder properties?

No. Removing units from zero values (0px → 0) can change meaning for properties like flex-basis, and reordering or merging properties can change cascade behaviour, so both are intentionally left out for safety.

What happens if I paste broken CSS?

If unbalanced braces, an unterminated string, or an unterminated comment is detected, the tool shows an error instead of silently returning a broken result, and the output stays empty.

Is my CSS sent anywhere?

No. Minification and beautification run entirely in your browser's JavaScript; nothing is sent to toco.tools's servers or anywhere else.