Home/Tools/Minifiers/CSS Minifier

CSS Minifier

Minifiers

Minify and compress CSS stylesheets to reduce file size.

⚡ Instant🔒 Private, in your browser🆓 Free, no sign-up👥 For developers
Your data never leaves your browser. We do not store inputs.

What CSS Minifier does

The CSS Minifier removes comments and unneeded whitespace from a stylesheet, producing a smaller file that downloads faster. Paste in your CSS, minify it in your browser and copy or download the result. It does not rewrite your values, and it keeps selectors like .a :hover, quoted strings and url() contents exactly as written.

FV
Reviewed by the FreeToolsVerse team · Last updated · How we check our tools

Features and benefits

  • Removes comments and unneeded whitespace without touching values, strings or url() contents
  • Keeps the space in descendant selectors such as .a :hover, which a careless minifier would break
  • Shows the size before and after and the percentage saved
  • Keeps /*! licence */ comments if you want them, and runs in your browser

How to use CSS Minifier

  1. Paste your CSS code into the input box
  2. Click Minify to compress it
  3. Compare the original and minified file sizes
  4. Copy or download the minified CSS

Who should use it

Made for developers. Typical uses:

  • Shrinking a stylesheet before deploying it to a production website to reduce load time
  • Removing comments and formatting from CSS before including it in a minified bundle
  • Checking how much a large CSS file compresses to decide if it's worth adding to a build pipeline

Example

A 251-byte stylesheet with comments, two button rules, a data-URL background and a content string with two spaces minifies to 203 bytes, about 19% smaller. The two spaces inside the quoted string and the data URL are untouched, and .btn{color:#fff;padding:8px 16px} replaces the indented block.

Limitations and accuracy

It removes comments and whitespace only: it does not shorten colours, merge rules, remove unused CSS, add prefixes or create source maps. Servers usually gzip or Brotli-compress CSS anyway, so the saving over the network is smaller than the figure shown.

Accuracy: Output is tested to keep behaviour unchanged. Keep your original files and test the minified version before you deploy it.

Expert Tip

Edit the readable source and publish only the minified copy. If a build tool already minifies your CSS, use this tool for quick jobs and to see how much a file could shrink.

Frequently asked questions

Will minifying change how my styles look?
It should not. Only comments and whitespace are removed. The tool keeps the space in selectors such as .a :hover, leaves quoted strings and url() contents as written, and never shortens colours or units. Open your page after minifying to be sure.
How much smaller will my CSS get?
It depends on how much of the file is comments and indentation. The tool shows the exact size before and after, so you can see the saving for your own stylesheet. Servers usually also compress CSS with gzip or Brotli, so the saving over the network is smaller than the figure shown.
Is it free to use?
Yes, completely free.
Is my code uploaded anywhere?
No, minification happens locally in your browser.
Can I reverse the minification later?
Not directly — keep your original, formatted CSS as the source of truth, and use a formatter to make minified CSS readable again if needed.

CSS Minifier: the complete guide

What the minifier does

The CSS Minifier makes a stylesheet smaller by removing the parts that browsers do not need: comments, line breaks, indentation and the spaces around braces, colons and semicolons. You paste your CSS, press Minify, and see the size before and after, the percentage saved, and the result, which you can copy or download as minified.css. It never changes what a rule means. Everything runs in your browser, so the stylesheet is not uploaded.

A worked example

Take a stylesheet of 251 bytes that contains a comment, two button rules, a rule with a selector that has a space before a pseudo-class, an icon background that uses a data URL, a content string with two spaces, and a licence comment. The minifier reduces it to 203 bytes, a saving of about 19 percent: the .btn rule becomes .btn{color:#fff;padding:8px 16px} and the hover rule follows it on the same line. The quoted content string "a b" keeps both of its spaces, the data URL is untouched, and the selector .a :hover keeps its space, because .a:hover and .a :hover mean different things. The licence comment survives at the end unless you turn the option off.

What it keeps on purpose

A careless minifier can break a page, so this one is conservative. It leaves quoted strings and the contents of url() exactly as written, keeps the space in descendant selectors, and preserves comments that begin with /! when "Keep /! licence */ comments" is on, which is how open-source licences are usually marked. It does not shorten colours such as #ffffff to #fff, merge rules, reorder properties or rewrite values like margin: 0 0 0 0. Those optimisations save a little more but can change behaviour in edge cases, so a build tool is the right place for them.

How much will you save?

The saving depends on how much of the file is comments and indentation. A well-commented, nicely indented stylesheet can shrink by a quarter to a half. One that was already compact saves little. The figure shown is the raw size, but servers normally also compress CSS with gzip or Brotli, which already removes much of the repeated whitespace, so the difference over the network is smaller. Minification is still worthwhile because the browser also has less text to parse. The guide to minifying CSS, JavaScript and HTML explains where each step fits in a build.

Good habits

Keep your readable source as the version you edit, and publish the minified copy. If you need to read a minified file again, the CSS Formatter restores indentation, although comments that were removed stay gone. Test the page after minifying, as with any change. Check that the stylesheet is valid first with the CSS Validator, because a minifier does not repair mistakes. For other files, use the JavaScript Minifier and HTML Minifier.

Limits

The tool minifies one pasted stylesheet at a time. It does not combine files, remove unused rules, add vendor prefixes or generate source maps. If your site uses a build tool such as a bundler, let it do the minifying automatically and use this tool for quick jobs, for checking how much a file would shrink, and for code that is not part of a build.

Learning resources

Explore more in Minifiers, read the guides and articles, or see how we test our tools.

Share This Tool