CSScompressor Nederlands

What breaks a CSS minifier?

Most minifiers treat CSS as plain text and use search-and-replace. That works until it does not, and when it fails it fails silently: the file still looks fine, but your page has changed. Below are seven constructs where it goes wrong, tested live in your own browser.

How this test works

Nobody has to take our word for it. Each example below is parsed twice by your browser's own CSS engine: once as the original, once as the minified result. If the two produce different rules, the minifier changed the meaning of your stylesheet. That is a verdict from the browser, not from us.

The “search-and-replace” column shows what a typical regex-based minifier does — the approach this very site used until November 2026. It is there as a demonstration of the method, not as a judgement of any particular tool.

This test needs JavaScript. The examples below are listed anyway.

  1. Text inside a string. The comma, the colon and the spaces are literal: this is what your visitor reads.
    .a::after { content: "een, twee: drie"; }
  2. A space before a pseudo-class is a descendant combinator. nav :hover targets the children, nav:hover targets the nav itself.
    nav :hover { color: red; }
  3. A data URI contains semicolons and commas that look exactly like the end of a declaration.
    .b { background: url("data:image/svg+xml;charset=utf8,%3Csvg%3E") no-repeat; }
  4. Inside calc() the spaces around the minus are required, and so is the unit on 0px. Two common optimisations each break this on their own.
    .c { width: calc(100% - 0px); }
  5. The spaces in these strings define the shape of your grid.
    .d { grid-template-areas: "kop kop" "zij main"; }
  6. Braces inside a string are text, not block delimiters.
    .e::before { content: "{ }"; }
  7. A custom property value is a raw token stream, and its name is case-sensitive.
    :root { --Mijn-Var: 0px 12px; }

Check your own minifier

Use another tool and want to know whether it is safe? Paste your original stylesheet on the left and the minified output of that tool on the right. Your browser parses both and reports every rule that came out different. Nothing is uploaded.

Why this matters more than the percentage

Every minifier advertises its saving. Almost none advertises its correctness, and the difference between 78% and 80% is a few hundred bytes you will never notice. One silently rewritten content value, on the other hand, is a visible defect on your page that you will spend an afternoon tracking down — because the stylesheet looks fine and the original works.

This is why our engine parses the CSS instead of pattern-matching it: strings, url() contents and everything inside parentheses are held aside before a single space is touched. It costs a few percent of saving. It is worth it.

Does a failed test mean the tool is bad?

It means that construct is handled unsafely. If your stylesheet never contains it, nothing happens to you. The trouble is that you cannot tell in advance, and the failure is silent.

Why compare with the browser instead of comparing text?

Because text differences are mostly harmless — that is the whole point of minifying. Only a difference in what the browser understands counts. Parsing both versions and comparing the resulting rules is the only check that answers the real question.

Is my pasted CSS sent anywhere?

No. The comparison runs in your browser with its own CSS parser. You can verify it in the network tab.

Other tools on this site

Read more