CSS Minifier

Lighthouse flagged unminified CSS on your landing page. Paste the stylesheet or drop the .css file, pick an output mode, copy the result. Raw plus gzip sizes update as you type, with calc() math, quoted strings, license headers left intact. Nothing leaves your browser.

CSS minifier workbench

Output
Options
498 B · 1 line
Raw831 B → 498 B
Gzip468 B → 336 B
Smaller by
40.1%
Comments dropped
3
Warnings
0

Paste CSS or drop a file to start.

Where the 333 bytes went in the sample

The editor opens with a 40-line card stylesheet written for Toolexe category pages. Full mode takes the file from 831 bytes to 498, a 40.1% cut. Each step below lines up with one checkbox or one rule in the minifier.

StepWhat changed in the sampleBytes
WhitespaceIndents, blank lines, spaces around { } : ; , >161
CommentsThree notes gone. The /*! license line stays.137
Empty rule.tool-card--legacy { } had zero declarations20
Shorter values#FFFFFF to #FFF, #0055aa to #05a, 0px to 0, 0.75rem to .75rem, 1.10rem to 1.1rem15
Total removed333

Value shortening earns the least. Turn the option off if a code reviewer wants to grep for #FFFFFF in the shipped file.

Raw size vs bytes on the wire

Most servers gzip or Brotli-compress CSS before sending. Compression already folds repeated spaces into short references, so minifying saves less over the network than the raw count suggests. The sample proves the point: raw drops 40.1%, gzip drops from 468 to 336 bytes.

We ran two files from the Toolexe repository through this exact code:

  • Hand-written theme, 2,801 lines. Raw 47,157 to 37,172 bytes (21.2% smaller). Gzip 9,000 to 7,881 bytes (12.4% smaller).
  • Admin theme built on Bootstrap 5.3.3, already minified. Raw 766,434 to 755,660 bytes (1.4%). Gzip 91,003 to 90,260 bytes (0.8%). The 748 KB file took about 120 ms in our Node test.

Three spots where careless minifiers break CSS

Stripping whitespace sounds safe. Three cases prove otherwise. The previous version of this page failed the first one.

  1. Math inside calc()

    The CSS spec requires spaces around + or - inside calc(), min(), max(), clamp(). A regex stripping spaces around every + outputs calc(100%+2rem). Browsers reject the declaration, so the width silently falls back to auto.

    width: calc( 100% - 2rem ); inputwidth:calc(100% - 2rem) this page
  2. The space before a colon in a selector

    .tool-card :hover styles any hovered element inside the card. .tool-card:hover styles the card itself. Same characters, different targets. The minifier keeps a space before a colon in selectors, removing colon spacing only inside declarations.

  3. Quoted strings & url()

    The sample badge uses content: "  new  ". Those padding spaces render on screen. Strings, plus unquoted url(data:...) values, pass through byte for byte, including any { or ; inside them.

Which output mode to pick

Full 498 B on the sample

One line, smallest file. Ship this to production or a CDN.

Rule per line 503 B

Each top-level rule, including a whole @media block, gets one line. A changed selector shows up as one changed line in a Git diff, for five extra bytes here.

Property per line 577 B

A quick read of compressed output, still without comments. For real formatting with consistent indents, open the CSS Beautifier.

Keep the /*! checkbox on when the file bundles MIT or BSD code such as Bootstrap or normalize.css. Both licenses ask for the copyright notice to travel with every copy, which is why most build tools treat /*! as "do not strip".

When this page is the wrong tool

CSS minifier questions

Rendering, license comments, privacy, gzip numbers, plus the IE hack warnings.

Will minified CSS render differently from the original?

Not for valid input. Whitespace outside strings carries no meaning in CSS, nor do comments. When the source has an unclosed brace, string or comment, the warning list flags the spot, since a browser guesses differently from the minifier at broken input.

Should I keep the /*! comment?

Keep the notice when the stylesheet includes MIT or BSD code such as Bootstrap or normalize.css. Those licenses ask for the copyright notice to stay with every copy. The checkbox starts on. Switch the box off only for code you wrote yourself.

Does my CSS get uploaded to toolexe.com?

No. Minification runs in JavaScript inside this browser tab. Dropped files are read with the FileReader API on your device. No request carries the stylesheet anywhere.

Why is the gzip saving smaller than the raw saving?

Gzip replaces repeated runs of characters, including long runs of spaces, with short back-references. Minified CSS has less repetition left to squeeze, so the two sizes converge. On the 2,801-line theme we tested, raw dropped 21.2 percent while gzip dropped 12.4 percent.

How do I turn minified CSS back into readable code?

Paste the output into the CSS Beautifier. Indents come back, comments do not. Keep the readable file in version control, then treat the .min.css copy as build output you regenerate.

What does the Internet Explorer hack warning mean?

Declarations such as *zoom: 1 or width: 100px\9 targeted IE 6 through 9. Modern browsers ignore them. The minifier keeps them so the output matches the input, but deleting them by hand saves bytes with zero visual change.