Byte-safe CSS compression: calc() spaces, strings and /*! banners survive.
.card{padding:0;margin:0 auto;border-radius:8px;box-shadow:0 2px 8px rgba(0,0,0,.15);font-family:"Open Sans",sans-serif}.card__title{font-size:1.5rem;line-height:1.2;letter-spacing:.02em}/*! keep this banner after minify */ @media (max-width:600px){.card{width:calc(100% - 32px)}}🛡️ Conservative by design: strings and /*! banners are protected before any whitespace work, calc() keeps the spaces its grammar requires, and 0% is never folded to 0 (they differ inside flex-basis). No aggressive rule merging, so output stays valid on the first try.
The CSS Minifier is based on the following formula:
savings% = (bytes_in − bytes_out) / bytes_in × 100
Variables: bytes_in = UTF-8 byte length of the pasted CSS bytes_out = UTF-8 byte length of the minified output savings% = relative size reduction shown above the result
Only byte-level folds are applied: comments stripped, whitespace collapsed, spaces around safe punctuation removed, trailing semicolons dropped, 0px→0 for absolute units and 0.5→.5. Spaces around + and − are never touched (calc() requires them), so the output stays valid without regression testing.
Worked example: Step 1: the default sample CSS is 370 bytes (TextEncoder counts UTF-8 bytes). Step 2: after minification it is 280 bytes — comments and whitespace gone, calc(100% - 32px) spaces preserved, 0px folded to 0. Step 3: savings = (370 − 280) / 370 × 100 = 90 / 370 × 100 ≈ 24.3%. Result: about 24% smaller — typical for commented, one-declaration-per-line CSS (the tool recomputes these numbers live for your input; byte counts verified against the implementation).
Hand-written CSS is mostly air: indentation, one declaration per line, section comments. Stripping comments and collapsing whitespace typically cuts 15-30% — but gzip squeezes whitespace extremely well, so the honest network win is smaller than the byte counter suggests. What minification really buys is parse time, a stable cache hash for a smaller artifact, and CSS small enough to inline above the fold without wrecking the HTML.
calc() requires whitespace around + and − — remove it and the declaration is dead. div :hover and div:hover are different selectors, so space before a colon stays. 0% and 0 are not interchangeable inside flex-basis. And string content (content: "…", font names, url()) must never be re-spaced. This tool pulls strings and /*! banners out as placeholders before touching whitespace, then folds only what is provably safe: 0px→0, 0.5→.5, trailing semicolons, empty rules.
Aggressive minifiers rewrite .a{color:red} .b{color:red} into .a,.b{color:red} — and when merged selectors have differing specificity or order-dependent overrides, the cascade shifts and a page 2,000 lines away quietly breaks. Byte-level folds never change meaning; selector merging sometimes does. The 5-10% extra compression is not worth a stylesheet that needs visual regression testing to trust.
Ship minified: production bundles, inlined critical CSS, style blocks inside components destined for publish. Keep readable: anything a teammate will open in devtools with the original sources available — source maps are the proper bridge, and a build pipeline (esbuild, cssnano, Lightning CSS) automates this. This tool is for the one-off paste: the email template, the CMS theme field, the quick fix that needs to be small right now.
More tools you might find useful
Convert CSV data to a JSON array using the header row.
CSV in, batched multi-row INSERTs out — with escaping and NULL options.
Turn curl commands into JavaScript (Fetch/Axios) and Python requests code.
BPM to delay times in ms for every note value, plus LFO rates.