CSS Minifier

Shrink stylesheets by removing comments and whitespace and shortening values. Shows the size before and after, including gzip size.

Loading tool…

About the CSS Minifier

The minifier tokenizes your stylesheet before changing anything, so strings (content: " /* not a comment */ ") and url() values are protected. It then applies only safe transformations: removes comments except those starting with /*! (the convention for license banners), collapses whitespace, removes spaces around { } : ; , and selector combinators, and drops the last semicolon in each block.

Values are shortened where the result is guaranteed to be equivalent: 0px → 0 for length units, 0.50em → .5em, #aabbcc → #abc. Zeros are left alone inside calc() and other functions — calc(100% - 0px) is valid but calc(100% - 0) is not — and for % and time units, because 0s and 0% are not interchangeable with 0 everywhere. Custom property values (--x: 0px) are kept verbatim since they may be used inside calc(). Selectors are never rewritten, so an ID like #aabbcc is safe.

Typical savings are 15–30% before compression. The status line also shows the gzip size, which is what users actually download when your server compresses responses. The tool does not merge rules or remove unused CSS; for that, use a build step with cssnano, Lightning CSS or PurgeCSS. Everything runs in your browser.

How to use it

  1. Paste your CSS or open a .css file.
  2. Review the minified output and size savings.
  3. Copy the result or download styles.min.css.

Frequently asked questions

Is it safe to minify CSS?
Yes, when the minifier respects CSS syntax. This one only removes whitespace and comments and applies value shortenings that are equivalent by spec, avoiding contexts like calc() where they are not.
Why is my license comment still there?
Comments starting with /*! are preserved on purpose, because many open-source licenses require the notice to be kept in distributed files.
Should I still enable gzip or Brotli?
Yes. Minification and HTTP compression complement each other: minified CSS usually compresses a little better, and the combination gives the smallest transfer size.

Related tools