How to Compress CSS Whitespace
CSS Whitespace Compression
What This Tool Does
Removes CSS comments and insignificant whitespace between rules and declarations. Selectors, property names, and values are preserved. This is a whitespace compressor — not a production build minifier like cssnano or clean-css.
What It Does Not Do
- Shorten colors (
#ffffffstays as-is) - Merge duplicate rules or remove unused declarations
- Optimize
calc()or rewrite vendor prefixes - Fix invalid CSS — malformed input is rejected with an error
When to Use It
Quickly one-line a stylesheet before pasting into a snippet, email, or ticket. For production bundles, use your build pipeline minifier and measure gzip size separately — whitespace removal alone may have limited impact after compression.
Frequently asked questions
Is this the same as a production CSS minifier?
No. It only removes comments and extra spacing. Build tools also optimize values, merge rules, and apply other transformations.
Will compress rename class names?
No. Selectors and values are preserved; only whitespace and comments are removed.
What happens with invalid CSS?
The tool returns an error instead of silently producing corrupted output. Fix syntax issues first, then compress.