Free Online CSS Minifier
The CSS Minifier removes comments and unnecessary whitespace from your stylesheets, shrinking file size for faster page loads. Strings (like font names or URLs) are preserved exactly.
Once the stylesheet is reduced, reviewing the properties it carries is easier with the CSS Formatter & Beautifier, and its composition can be reconsidered with the CSS to Tailwind Converter. For a single-filter effect instead of a full sheet, the CSS Filter Generator is the tool.
How to use the CSS Minifier
- 1 Paste your CSS or load a file.
- 2 Minify. Whitespace, comments, the final semicolon in each block and redundant units are removed.
- 3 Compare the size before and after.
- 4 Test the page afterwards, since a minifier can expose a syntax error that the browser tolerated.
Where the real savings are
Minifying CSS is the last few per cent of a stylesheet's cost. The larger wins are removing unused rules, splitting critical CSS to inline above-the-fold styles, and avoiding loading a large framework for a page that uses a handful of its classes.
That said, minification is free and safe, so there is no reason not to do it as part of a build. Just sequence it correctly: purge unused rules first, then minify what remains, rather than minifying a stylesheet that mostly contains classes the page never uses.
- Removes comments, whitespace and redundant semicolons.
- Shortens values where safe, such as `0px` to `0`.
- Keep spaces inside `calc()` — they are required.
- Purge unused rules before minifying, not after.
Frequently asked questions
How much does CSS minification save?
Typically 15 to 25 per cent before compression, and much less after it, since gzip already handles the repetitive structure of a stylesheet well. The saving is real but modest, and it comes with no downside provided the stylesheet was valid to begin with.
Can minification break my CSS?
It can reveal a problem rather than create one. Sloppy CSS that browsers forgive — a missing semicolon before a closing brace, an unclosed comment that swallowed a rule — may behave differently once the minifier normalises it. If a style disappears after minifying, the original had a syntax error that happened to be tolerated.
What about custom properties and calc?
A good minifier leaves `var(--x)` and `calc()` expressions intact, because the values inside them are significant whitespace-wise in the case of `calc`. Be cautious with tools that strip whitespace aggressively inside function arguments, since `calc(100% - 2rem)` requires spaces around the minus operator.
Related Developer Tools
You might also need
Tools from other categories that people pair with the CSS Minifier: