CSS Minifier & Beautifier

Compress stylesheets for production or format minified CSS for readability — with VS Code syntax highlighting and instant byte savings.

Share this tool
VS Code syntax highlighting
Preserves /*! */ license comments
Load example:

Processing CSS...

Paste your CSS above and click Minify or Beautify.

What Is CSS Minification?

CSS minification removes characters that browsers ignore — whitespace, tabs, newlines, and comments — without changing how your stylesheet applies to the page. The browser parses minified CSS identically to formatted CSS; the only difference is fewer bytes traveling over the network.

Real-world minification typically saves 30–70% of the original file size, depending on how many comments and how much indentation the source contains. A stylesheet with generous spacing and block comments at the top of each component will compress more than one already written without whitespace.

Production build tools — Webpack, Vite, Parcel, and Rollup — minify CSS automatically as part of their output pipeline. This tool is useful when working directly with .css files outside a bundler, when you receive a third-party stylesheet you want to re-serve, or when you need to check how much a specific file can be reduced.

What Gets Removed During Minification?

Removed

  • • All /* ... */ comments (except /*! ... */)
  • • Newlines, tabs, and extra spaces between tokens
  • • Whitespace around { } : ; ,
  • • Trailing semicolons before }
  • • Leading zeros in decimals: 0.5rem → .5rem

Preserved

  • • /*! ... */ license and preserved comments
  • • All string content inside " " and ' '
  • • url() values verbatim
  • • Descendant combinator spaces (e.g. .parent .child)
  • • !important declarations

CSS Beautifier — When to Use It

The beautifier is the reverse operation — it takes minified or poorly-formatted CSS and adds consistent 2-space indentation, one declaration per line, and a blank line between rule blocks. The output is the same CSS, just formatted for human readability.

Use the beautifier when you need to:

  • • Debug a third-party stylesheet linked from a CDN (inspect its rules without reading one long line).
  • • Review a pull request where minified CSS was accidentally committed instead of source.
  • • Understand a vendor stylesheet when the original source files are not available.
  • • Onboard onto a legacy project that has no build pipeline and ships raw minified files.

How Much Can Minification Save?

StylesheetOriginalMinifiedSavings
Bootstrap 5 full~200 KB~157 KB~21%
Hand-written component CSS~5 KB~2.5 KB~50%
Comment-heavy source file~10 KB~3 KB~70%
Tailwind production buildAlready minified by Tailwind CLI—

Minification vs Gzip / Brotli

These are two separate, complementary optimisations that work at different stages:

  • Minification is a one-time transform you apply to the source file before deploying it. It permanently removes redundant characters. The result is stored on disk.
  • Gzip / Brotli is transport compression applied by your server or CDN on every request. The browser decompresses it automatically; you do not need to do anything client-side.

Always minify first, then serve with gzip. Minified files compress a further 10–15% better than unminified ones because shorter repeated patterns compress more efficiently. A 10 KB CSS file minified to 4 KB, then gzipped, can reach under 1.5 KB on the wire.

Frequently Asked Questions

Is minified CSS valid CSS?
Yes. Browsers parse minified CSS identically to formatted CSS. Whitespace and comments carry no semantic meaning in CSS; removing them does not change any selector, specificity, cascade order, or computed value.
Will minification break my styles?
Not with this tool. The minifier is conservative — it only removes whitespace and regular comments, strips trailing semicolons before }, and shortens 0.5 to .5. String content, url() values, and descendant combinator spaces are all preserved exactly.
Can I keep license comments during minification?
Yes. Use /*! ... */ — note the exclamation mark after the opening /*. Preserved comments survive minification verbatim. This convention is honored by this tool, UglifyJS, Clean-CSS, and most production minifiers.
What is the difference between minify and uglify?
Both terms describe removing whitespace and comments, but "uglify" (from the JavaScript tool UglifyJS) additionally renames variables, function names, and parameters to shorter single-letter identifiers. CSS has no equivalent — you cannot rename .button to .a without breaking your HTML. CSS minification is therefore always safe and fully reversible via the beautifier.
Should I minify CSS in development?
No. Keep your source CSS readable during development — browser DevTools, source maps, and debugging tools all depend on structured, line-numbered CSS. Minification belongs exclusively in your production build pipeline. Your build tool (Webpack, Vite, Parcel) handles this automatically when you run a production build.
What is CSS pretty-printing?
Pretty-printing and beautification are the same thing — reformatting compressed or hand-written CSS with consistent indentation, one declaration per line, and blank lines between rule blocks. The output is identical in behavior to the input but formatted for human readability.

Related Tools