CSS Minifier
Strip comments and whitespace from a stylesheet without touching what is inside a string or a data URI.
Runs entirely in your browser
Loading tool...
How to use
- Paste the stylesheet, or the block you are about to inline.
- Read the size saved — that is the number that reaches the visitor.
- Copy the result, or download it as a .min.css file.
- Keep the original: this output is for serving, not for editing.
Features
- Comments removed, including multi-line ones.
- Whitespace collapsed, and dropped entirely where CSS does not need it.
- Strings, `url()` values and data URIs left byte-for-byte intact.
- The redundant last semicolon in each block removed.
- Runs entirely in your browser — no stylesheet is uploaded.
Frequently asked questions
- Why do strings and data URIs need special treatment?
- Because they contain the very characters a minifier looks for. `content: "/* hi */"` is text, not a comment; a `data:image/svg+xml;base64,…` URI is full of semicolons that mean nothing to CSS. A minifier built out of regular expressions cannot tell the difference, and eventually eats one of them. This one reads the stylesheet character by character and steps over both.
- Will it rewrite my colours or merge my rules?
- No. Turning `#ffffff` into `#fff` or merging duplicate selectors is what a full optimiser does, and it is where minifiers introduce bugs — a merged rule can change the cascade. This removes only what is provably meaningless: comments, redundant whitespace and the trailing semicolon in a block.
- How much should I expect to save?
- Typically 10–30% of a hand-written stylesheet, most of it whitespace and comments. Over the wire the saving is smaller, because gzip already compresses repetitive whitespace well — minifying still helps, but the headline percentage here is not the number your visitors download.
Related tools
Shrinks HTML without changing what it renders — the space between two inline elements is a word gap, and it is kept.
px, rem, em, pt and % against the font sizes you actually use — one value, or a whole stylesheet at once.
Strip whitespace to make JSON as small as possible.
Escape text so a browser renders it instead of running it — and read entities back into the characters they stand for.
Convert text to Base64 and back again.
Build layered box shadows that look like elevation instead of a grey halo, and paste an existing one back in to edit it.