CSS Minifier

Paste a stylesheet to strip whitespace and comments, shorten values like #ff0000 → red, and merge duplicate rules with CSSO's structural optimizations.

Runs in your browserNo sign-upNothing uploaded

Minified output

How to use the CSS Minifier

  1. Paste CSS or open a .css file.
  2. Keep Restructure on to merge rules and declarations, or turn it off for a safe whitespace-only pass.
  3. Leave Keep license comments on to preserve /*! … */ notices.
  4. Compare the original, minified and gzipped sizes.
  5. Copy the result or download output.min.css.

How CSS minification works

This tool uses CSSO (CSS Optimizer), which parses your stylesheet into a syntax tree and prints it back in the shortest equivalent form. Beyond removing whitespace and comments it applies safe value rewrites:

  • #ffffff → #fff, #ff0000 → red
  • 0px → 0, 0.90 → .9
  • margin: 8px 16px 8px 16px → margin:8px 16px
  • Empty rules and duplicate declarations are dropped

What does “restructure” do?

Restructuring looks across the whole stylesheet: rules with identical declarations are merged into one selector list (.a,.b{color:red}), and repeated selectors are combined. This often saves another 5–15% on real stylesheets. CSSO only merges when the cascade order stays the same, but if you rely on unusual overrides you can switch it off for a purely syntactic minification.

Why minify CSS?

CSS blocks rendering: the browser cannot paint the page until stylesheets in the <head> are downloaded and parsed. Smaller CSS means a faster First Contentful Paint and better Core Web Vitals, which helps both users and search rankings. Combine minification with gzip or Brotli on the server for the best result.

Frequently asked questions

Is it safe to minify CSS?
Yes. Whitespace and comments have no effect on how CSS renders, and CSSO's value rewrites are equivalent by specification. Restructuring keeps cascade order; disable it if you want the most conservative output.
Does it support modern CSS such as custom properties, nesting and @layer?
Yes. Custom properties (--var), @media, @supports, @layer, @container and grid syntax are preserved.
Can I un-minify CSS later?
Minified CSS can be re-indented by any formatter, but removed comments cannot be recovered. Keep your original source file and treat the minified file as a build output.
Is my stylesheet uploaded anywhere?
No. Minification runs in your browser; nothing is sent to a server.

Related tools