toolo.dev

CSS Minifier

Minify CSS online without breaking it: url(), strings, calc() and media queries stay valid. Keeps license comments, shows bytes saved, formats minified CSS.

After you click or type in the editor, the Tab key indents. Press Escape, then Tab, to move to the next field.

About the CSS Minifier

A CSS minifier should make your stylesheet smaller and change nothing else. This one removes comments, line breaks and indentation, and leaves alone every space that carries meaning: inside strings and url() paths, around the minus in calc(100% - 2rem), after and in a media query, and in a selector like .nav :hover.

It reads the CSS with a tokenizer, not search-and-replace, so it knows where a string or comment really ends. Values stay as you typed them and rules keep their order, so the output is the same stylesheet with less whitespace. Format mode does the reverse with Prettier. Both run in your browser.

  1. Paste your stylesheet into Input CSS, or click Load Example for one with a license comment, url(), calc(), nesting and a media query.
  2. Minify is already selected, so Minified CSS fills in as soon as you pause, with Original Size, Minified Size and Savings above it.
  3. If a brace is missing, or a comment, string or url( is never closed, CSS Error replaces the output and gives the position, for example Line 1, column 4: "{" is never closed. That line number turns red in the input.
  4. Click Format to read minified CSS. Prettier's version appears in Formatted CSS, and your input stays as it is.
  5. Copy the result, or download it as minified.css or formatted.css.