CSS

CSS Minifier

Details

How to use CSS Minifier

What the tool does, how to run it, and what to expect from the result.

How to minify CSS

Minifying CSS strips comments and collapses the whitespace that exists purely for human readers. The result is functionally identical to the input, and typically 15 to 25% smaller before compression.

The transform runs in your browser. It is a pragmatic whitespace and comment pass rather than a full CSS parser, which makes it quick and dependency-free, and means it is worth a glance at the output when the input contains quoted strings.

  • Paste your stylesheet into the input box.
  • Copy the minified output, which has comments removed and whitespace collapsed.
  • Compare the file sizes shown so you know what you actually saved.
  • Check any declaration containing a quoted string, such as content or a font family with spaces, because the space handling inside strings is not preserved.
  • Keep the readable version in version control and treat the minified file as a build output you never edit.
Tips

Getting a better result out of CSS Minifier

Specific settings and thresholds, not general advice.

  • Quoted strings are left alone. A content value such as "Hello, world" keeps its comma and its space, because the scanner knows it is inside a string rather than between two selectors.
  • The real size problem in most stylesheets is unused rules, not whitespace. A typical site ships a framework of which it uses a fraction, and no minifier removes a rule you never applied. Tools that analyse your markup and strip dead selectors save an order of magnitude more than whitespace removal.
  • This is a regex-based transform, not a CSS parser. That makes it fast and predictable on ordinary stylesheets, and it means it can misread the unusual ones. Check the output if your CSS contains quoted strings, escaped characters, or hacks.
  • Keep the readable version as your source of truth. Minified CSS should be a build artefact, generated on the way to production, never the file you edit. If the only copy of a stylesheet is the minified one, you have lost the source.
  • Minified CSS costs you debuggability. Everything lands on line 1, so DevTools points every rule at the same location. Real build pipelines emit a source map alongside the minified file to restore that, and a browser tool cannot.
Limits

What CSS Minifier does not do

The honest boundary, so you do not lose time finding it yourself.

  • It does not preserve spaces inside quoted strings. A declaration such as content: "Hello, world" has the space after the comma removed, which changes what is rendered on the page.
  • It does not distinguish a descendant combinator from a pseudo-class. A selector written as a space followed by a colon is collapsed, so a :hover becomes a:hover and the rule now matches a different element.
  • It removes no unused rules, merges no duplicate selectors, and shortens no hex colours or longhand properties, all of which a real optimiser does.
  • It emits no source map, so debugging the minified output in DevTools points every rule at line 1.
At a glance

Who CSS Minifier is for

A quick way to understand who this helps, what it solves, and where it connects next.

Best fit

Developers and anyone working with code who needs quick formatting.

Ideal for

Quickly minify CSS without a build step or install.

FAQ

Common questions

Short answers for the questions people usually have before trying a utility like this.

Is minifying CSS worth it if my server uses gzip or brotli?

Less than most people assume. Compression algorithms are extremely good at the exact redundancy that minification removes: repeated whitespace, repeated property names, repeated selector patterns. Measured on real stylesheets, minification typically cuts 15 to 25% of raw bytes, but once both the minified and the pretty version are gzipped, the gap between them often narrows to a few percent. It is still worth doing in a build, because a few percent on a render-blocking resource is real, but it is not where the big wins are.

What actually makes a stylesheet smaller, if not whitespace?

Deleting rules you do not use. Most sites load a CSS framework and apply a small fraction of it, and the dead selectors survive every minifier because a minifier has no idea what your HTML contains. Tools that scan your templates and remove unmatched selectors routinely cut a stylesheet by 80 or 90%. After that, splitting the critical above-the-fold CSS from the rest matters more than any byte-level trick.

Should I check the output rather than trusting it?

Yes, particularly if your CSS is unusual. This is a whitespace and comment transform driven by regular expressions rather than a full CSS parser, which is why it is instant and dependency-free. The consequence is that it cannot reason about context: it does not know that a comma inside a quoted content string is data rather than a separator, and it does not know that a space before a colon might be a descendant combinator. On ordinary stylesheets it is fine. On clever ones, diff the output.

Can I edit the minified file directly?

You can, but you should not. Minified CSS is a build artefact. Once it is the only copy, you have lost the comments, the structure, and the ability to review a change in a diff. Keep the readable stylesheet in version control, minify as part of your deploy, and never hand-edit the output, because the next build will overwrite whatever you changed.

Is my CSS uploaded anywhere?

No. The transformation runs in your browser as a set of string operations. Stylesheets sometimes contain internal URLs, unreleased class names, or comments about a client, so nothing is transmitted or stored.

Recommendations

You Might Also Like

Nearby tools from the catalog that fit the same job or workflow.

Cleanor app

Do it all on your device

Cleanor puts these tools in one app: compress and convert images, video, and audio, work with PDFs, and scan text right on your device. Plus free up storage and clear inbox clutter with Email Cleaner. Start with a free trial.

  • iPhone
  • Android
  • Macsoon
  • Windowssoon