CSS Minifier

Compress stylesheets for production. This CSS minifier removes whitespace and comments, shortens colors and zero values, merges duplicate rules safely and shows the bytes and gzip size you save.

Press Ctrl+Enter (⌘+Enter on Mac) to run now.

Original–
Minified–
Saved–
Gzipped–
Linecolumn

Minify CSS Online

CSS is render-blocking: the browser waits for every stylesheet in the <head> before it paints the page, so a smaller file means a faster first view. This CSS minifier removes everything the browser does not need, such as indentation, line breaks, comments and the last semicolon in each rule, and then rewrites values into shorter equivalents.

It uses CSSO (CSS Optimizer), a structural minifier that parses the stylesheet into a syntax tree instead of running regular expressions over text. That lets it merge duplicate rules and declarations only where the cascade stays the same. License comments marked with /*! are kept, and the panel below shows the original and minified size, the percentage saved and a gzip estimate. Everything runs in your browser.

Formatted CSS rules compressed into one linea {a{colorCSSMinifier

How to minify CSS

  1. Paste your stylesheet or open a .css file.
  2. Choose what happens to license comments: keep every /*! … */ comment, keep only the first, or remove all comments.
  3. Leave “Merge and restructure rules” on for the smallest safe output, or turn it off to only compress each rule in place.
  4. Read the savings panel for the size before and after, the percentage saved and the gzipped size.
  5. Copy the result or download it as styles.min.css. Syntax errors are reported with the line and column.

What the CSS minifier optimizes

OptimizationBeforeAfter
Whitespace and line breaksa { color: red; }a{color:red}
Comments (except /*!)/* Buttons */removed
Last semicolon in a rule{color:red;}{color:red}
Zero unitsmargin: 0pxmargin:0
Leading zeros and trailing zeros0.30s.3s
Colors#FFFFFF, #ff0000, rgb(67, 56, 202)#fff, red, #4338ca
Keywordsfont-weight: bold, border: nonefont-weight:700, border:0
Repeated shorthand valuesmargin: 0 0 0 0margin:0 (with restructuring)
Duplicate selectors.card{padding:0} .card{margin:0 auto}.card{padding:0;margin:0 auto}
Identical declarations.btn and .link with the same colors.btn,.link{…}

Why the result is safe

The CSS cascade depends on the order of rules, so moving or merging rules can change which style wins. CSSO only merges when it can prove the outcome is the same: it will not move a rule past another rule that sets a conflicting property on matching elements, and it does not move rules across /*! comments. It also keeps values where a shorter form would change meaning, for example calc(100% - 0px) and flex: 1 1 0px keep their units, because zero without a unit is invalid or different there.

“Merge identical @media blocks” is off by default for a reason: joining two separate @media (min-width: 768px) blocks moves rules past whatever sits between them, which can change the cascade. Turn it on only if your media queries do not override each other.

Minify, then compress

Minification and gzip or Brotli compression work together. Compression removes repetition at the byte level; minification removes characters and rewrites values, so the gzipped minified file is still smaller than the gzipped original. The gzip estimate is computed in your browser with the CompressionStream API, so treat it as an approximation of what your server sends. If your server does not compress CSS yet, enable it; on Apache, the .htaccess Generator can generate the rules together with long cache lifetimes.

Tips for faster stylesheets

  • Keep the readable source in version control and minify as a build step; to read a minified file again, run it through the CSS Beautifier.
  • Remove unused CSS first. A minifier cannot know which selectors your pages use; deleting unused framework rules usually saves far more than minifying.
  • Inline small images carefully: a tiny icon converted with Image to Base64 saves a request but grows the stylesheet by about a third of the file size, and larger images belong in the Image Compressor instead.
  • Minify the rest of the page too with the HTML Minifier and the JavaScript Minifier.

Frequently Asked Questions

Common questions about minifying CSS.

Paste the CSS into the left box. The minified stylesheet appears on the right along with the bytes saved and a gzip estimate; copy it or download it as a .css file.

Yes. CSSO parses the stylesheet and only applies changes that keep the same result, including rule merging, which it performs only when the cascade order is not affected.

Yes. Comments that start with /*! are kept by default, which is the usual convention for copyright and license notices. You can keep only the first one or remove all comments.

It depends on the source. Hand-written CSS with indentation and comments shrinks noticeably, while files that are already compact gain less. The savings panel shows the exact numbers for your file, including the gzipped size.

It combines rules with the same selector, groups selectors that share identical declarations and folds longhand properties into shorthands where safe. Turn it off if you want each rule to stay in place.

A missing brace, an unclosed string or a stray character can make the parser skip part of the stylesheet. The message shows the line and column so you can fix it; the skipped part may be missing from the output.

No. Compile SCSS or Less to plain CSS first, then minify the compiled file. Preprocessor syntax such as nesting with & or variables with $ is not plain CSS.

No. The CSSO library is downloaded once and minification runs entirely in your browser.