Skip to content

CSS Minifier — Compress CSS Code Online

Minify and compress CSS code instantly — shows size savings. Free, private, and browser-based.

Last updated:

What CSS Minification Does

CSS minification reduces file size by stripping everything a browser does not need to interpret your styles. Whitespace, line breaks, block comments, and semicolons before closing braces are all removed without changing how the stylesheet renders. A well-written minifier also rewrites values into shorter equivalents: #ffffff becomes #fff, font-weight: bold becomes font-weight:700, and longhand properties like margin-top/right/bottom/left may be collapsed into a single margin shorthand.

The savings depend on coding style. Heavily commented, well-formatted source files can shrink by 20-40% from minification alone, and even more once the minified output is served with Brotli or gzip compression. Because CSS is a render-blocking resource, every kilobyte you remove directly improves First Contentful Paint and Largest Contentful Paint scores.

Minification in the CSS Build Pipeline

Most production projects run CSS minification as a build step. PostCSS with the cssnano plugin is the most widely adopted approach; it chains dozens of micro-optimizations like merging duplicate selectors, discarding overridden declarations, and normalizing Unicode ranges. Lightning CSS (formerly Parcel CSS) is a newer, Rust-based alternative that combines minification with transpilation and is significantly faster on large stylesheets.

An online minifier like this one fills a different gap. It is useful when you need to minify a snippet before pasting it into an HTML email, a CMS template, or an inline <style> block where no build pipeline exists. It is also handy for quick before-and-after comparisons when evaluating how much a particular refactor would save on the wire.

CSS Minification vs. Tree-Shaking

Minification and tree-shaking (or purging) solve different problems, and neither replaces the other. Minification compresses the CSS you do use by rewriting it in fewer bytes. Tree-shaking removes the CSS you do not use by scanning your HTML and JavaScript for class references and discarding rules that match nothing.

  • Minification is safe on any stylesheet because it only removes syntactically redundant characters.
  • Tree-shaking requires a content scan and can produce false positives if class names are constructed dynamically at runtime.

For the best results, run tree-shaking first to eliminate dead rules, then minify what remains. Tools like PurgeCSS and Tailwind CSS's built-in content scanning handle the removal stage; this CSS minifier handles the compression stage.

Related Tools

If you are optimizing front-end assets, you may also find these tools helpful:

Frequently Asked Questions

What does CSS minification do?
It removes comments, unnecessary whitespace, and redundant characters (like trailing semicolons) from your CSS. This reduces file size for faster page loads without changing how the styles render.
Is this safe for production CSS?
Yes for standard CSS. The minifier uses conservative transformations that preserve the meaning of your styles. It does not modify property values, reorder rules, or merge selectors.
Is my CSS kept private?
Yes. This tool runs entirely in your browser. Your CSS is never sent to any server.
Does minification affect CSS cascade order?
No. Rule order is preserved exactly. Minification only strips whitespace, comments, and redundant characters (trailing semicolons, unnecessary quotes). Computed styles are identical.
How much does a typical stylesheet shrink?
Uncompressed CSS typically shrinks by 20-30%. After gzip (standard browser behavior), the additional savings over unminified-but-gzipped CSS is smaller — usually around 5-10%.
Should I minify Tailwind CSS output?
The Tailwind CLI and Vite plugin already minify in production mode and purge unused classes, which is a much bigger win than post-minification. Use this tool for hand-written CSS or legacy stylesheets.

Related Tools