CSS minifier

Minify CSS in your browser: nothing is uploaded, there is no limit on the size, and you see the saving in characters and percent. Comments and unnecessary spaces go; your styles work exactly the same.

How it works

  1. Paste your code

    Paste the code in the left box or open a file. No code to hand? Click Example.

  2. Instant result

    The result appears as you type. If there is an error, you see the line and character.

  3. Copy or download

    Copy the result with one click or save it as a file for your editor or project.

What gets removed?

Comments, line breaks, indentation and the spaces around {, }, :, ; and ,. The last semicolon of every block goes too. Spaces that matter stay: inside strings, in url(), in calc(100% - 2rem) (where the spaces around - are required) and between the parts of a value such as margin: 0 auto.

Licence comments

Comments starting with /*! usually contain a licence that has to stay. Tick Keep /! … / comments and they remain in the output.

How much will you save?

It depends on how the stylesheet was written. A commented, well-indented file often shrinks by a quarter to a third; a file that was already compact saves far less. The size summary gives the exact numbers for your CSS. Remember that web servers normally compress CSS with gzip or Brotli as well, so the real saving on the wire is smaller than what you see here, but the two add up.

What minifying does not do

This tool removes whitespace and comments. It does not merge selectors, remove unused rules or rename anything, because that is what bundlers and tools such as cssnano or Lightning CSS do. If you have a build process, put minification there. For a quick job, such as a snippet for an e-mail template or a CMS field that only accepts one line, this page is the fastest way.

Test the result

After minifying, look at the page once. The most common problem is a missing semicolon in the source that the browser used to forgive but that now merges two rules into one. Format the result again with the CSS beautifier if you need to find it.

See also: CSS beautifier · HTML formatter.

Frequently asked questions

Is minified CSS safe?

Yes, if the original is valid. Strings, url() values and spaces inside calc() are kept exactly.

Are licence comments kept?

Comments that start with /*! can be kept with the option for it, so licences stay in the file.

Do I still need gzip?

Yes. Minifying and server compression work together; use both.

Is my CSS uploaded?

No. It is minified in your browser and never sent anywhere.