CSS Minifier

Remove CSS comments, redundant whitespace and empty rules.

  • Runs locally in your browser
  • No upload required

Try it

Paste a stylesheet. Strings and url() values are preserved.

Minified CSS
.a{color:#fff}
Size
33 → 14 characters (19 saved)

Supported formats

Input
text, boolean
Output
text

Privacy

Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.

Processing
In your browser
Privacy level
Browser only

Reduced 33 to 14 characters of CSS.

How it works

  • Removed comments, keeping /*! licence comments.
  • Removed whitespace around braces, colons, semicolons, commas and combinators.
  • Dropped the final semicolon in each block.
  • Strings and url() values are copied exactly, so values that need spaces stay valid.
  • Minifying the result again changes nothing.

Methodology

  1. Tokenise the stylesheet, treating strings and comments as opaque.
  2. Remove comments unless disabled, preserving /*! licence comments.
  3. Collapse whitespace around structural punctuation and drop the final semicolon in a block.

Usage

  1. Paste or type a CSS stylesheet.
  2. Choose whether to remove comments.
  3. Run the minifier and copy the smaller stylesheet.

Examples

These are examples, not current values: they use fixed inputs, while the interactive tool computes live results in your browser.

Whitespace and comments removed

jsonSelect to copy
{
  "text": ".a {\n  color: #fff; /* note */\n}\n",
  "removeComments": true
}

Licence comment kept

jsonSelect to copy
{
  "text": "/*! (c) me */ .a { color: red; }",
  "removeComments": true
}

Calc spacing preserved

jsonSelect to copy
{
  "text": ".a { width: calc(100% - 10px); }",
  "removeComments": true
}

Limitations

Smaller stylesheets

Removing comments and structural whitespace shrinks a stylesheet without changing any declaration. Values that require spaces are detected and preserved.

Frequently asked questions

Can minifying break calc()?
No. Whitespace that is required inside values is preserved; only whitespace around structural punctuation is removed.
Are licence comments kept?
Yes. Comments beginning with /*! are preserved so required notices survive.
Is my stylesheet uploaded?
No. The stylesheet is processed entirely in your browser.

Sources

  1. CSS Syntax Module Level 3 — W3C
  2. MDN Web Docs — CSS reference — MDN