How to use the CSS minifier
- Choose Minify or Beautify.
- Paste your CSS or drop
.cssfiles (several at once for a batch). - Pick the engine and options for Minify: Lightning CSS (safe) or CSSO (structural), keep license comments, create a source map. For Beautify, choose the indentation.
- Press the button. The first run loads the engine in a background worker.
- Copy or download the result, open the diff view or measure gzip and brotli sizes.
How it works
| Engine | What it does | When to use it |
|---|---|---|
| Lightning CSS (default) | Parses CSS, removes whitespace and comments, shortens colors and values, merges longhands into shorthands where equivalent | Almost always: output behaves exactly like the input |
| CSSO, structural | Everything above, plus merging identical rules and declarations across the stylesheet | When every byte counts and you can test the result |
| js-beautify | Re-indents rules, nested rules and at-rules, one declaration per line | Reading or debugging minified CSS |
License comments (/*! … */) are preserved unless you turn the option off.
Worked examples
.card { color: #ff0000; margin: 0px 0px 0px 0px; }becomes.card{color:red;margin:0}with Lightning CSS.- Two rules for
.buttonwith different padding: CSSO can merge them into one, keeping the last value, which is why it warns that structural changes can affect the cascade. - A one-line third-party stylesheet: Beautify turns it into indented, readable rules.
Tips and common mistakes
- Edit the source, not the minified file. Beautify a minified file first if it’s all you have, then minify again.
- Keep license comments for third-party CSS; many licenses require it.
- Combine before you minify so whitespace between files is removed too.
- Always serve CSS with gzip or brotli; the savings multiply.
How minification fits a build pipeline
Most production sites minify CSS automatically: bundlers such as Vite, webpack and esbuild run a minifier when you build for production, and Lightning CSS is one of the engines they use. This tool helps when you don’t have a build step, such as a small static site, a theme, an email template or a CMS snippet, or when you want to check what a minifier would change.
Privacy
Stylesheets can contain internal URLs, client names or unreleased product names in comments and selectors. Because this tool runs entirely in your browser, nothing you paste leaves your device.