Skip to content
cliplimeClipLime

Minify CSS safely

Remove comments and white space from CSS and see how many bytes you save. Colors, values and rule order are never rewritten.

Your text is processed in this tab and never uploaded

Options

Comments that start with /*! stay, as licenses often require.

a{color:red;} becomes a{color:red}. This is the only character removed that is not white space or a comment.

0 characters, 0 lines Your text stays in this tab.

Only comments and white space are removed. Colors, numbers, selectors and rule order are never rewritten, and the text of custom properties (--name) is copied as written.

At a glance

What it removes
Comments and white space, plus the last semicolon in each block if you leave that option on.
What it keeps
Strings, url() contents, escapes, and the text of custom properties (--name) as written.
Never rewritten
Colors, numbers, units, selectors, values and the order of rules.
License comments
Comments that start with /*! are kept by default.
Stops on
An unclosed comment, string or url(, with its line and column, instead of producing a broken result.
Size line
Shows the size before and after in bytes, and the percentage saved.
Privacy
Runs in your browser tab. Your CSS is never uploaded.

How to do it

  1. 1

    Paste your CSS

    Paste plain CSS into the left box or drop a .css file on it. Minify mode is already selected.

  2. 2

    Choose two options

    Decide whether /*! license comments stay, and whether the last semicolon in each block is removed.

  3. 3

    Check the size line

    Under the result you see the bytes before and after, and how many comments were removed.

  4. 4

    Copy or download

    Press Copy or Download. The file is saved as styles.min.css.

What gets removed

This minifier is deliberately limited to things that cannot change how the CSS behaves.

  • Comments, except the license comments that start with /*! if you keep them.
  • Spaces, tabs and line breaks at the start and end of the text and between rules.
  • White space around {, }, ; and ,, after (, [ and :, and before ) and ].
  • White space around the > and ~ combinators in selectors.
  • Optionally, the last semicolon before a closing brace. a{color:red;} becomes a{color:red}. This is the only character removed that is not white space or a comment.

What is deliberately left alone

  • The space before a colon in a selector. a :hover and a:hover select different things, so it stays.
  • Spaces around +, -, * and /. Inside calc() they are required, and + is also a selector combinator, so a space is never removed there. A run of spaces becomes one.
  • Strings and url(). Their contents are copied exactly, including semicolons and braces inside them.
  • Custom properties. The value of --name: ... is copied as written, because scripts can read it back with getPropertyValue.
  • A comment between two parts of one word. It stays rather than joining the parts.
  • Escapes. A backslash and the character after it are kept together.

What this minifier does not do

It does not shorten colors (#ffffff to #fff), drop units from zero, merge rules, remove unused CSS, add vendor prefixes, or inline @import. A full CSS optimizer in your build tool does those and saves more, with more risk. What you save here depends on how much white space and how many comments the file has. A well commented, indented stylesheet shrinks a lot. A file that is already compact barely changes.

It also does not minify SCSS or Less. A // line comment is not a CSS comment, so it would join the next rule. Compile to CSS first, then minify the result.

Using minified CSS safely

  • Keep the formatted file as your source and treat the minified file as a build output.
  • Serve it with gzip or Brotli compression. Compression removes much of the cost of white space on the network, so minifying matters most where text is stored or sent without compression.
  • Test the page after you switch. Because only white space and comments change, differences should not appear. If one does, keep your original file and compare the two.
  • Need to read minified CSS again? Paste it into the CSS formatter. Removed comments cannot be restored.

Questions people ask

Is minified CSS safe to use in production?

The changes are limited to comments, white space and optionally the last semicolon in a block, none of which change what the CSS means. It is still wise to test the page after switching, as with any build step.

Why are some spaces kept?

Where white space has meaning in CSS it must stay. A space between selectors is a descendant combinator, spaces inside calc() are required, and a space between two values separates them. The minifier removes only the white space that has no meaning.

Why keep comments that start with /*! ?

Licenses of libraries often require their notice to stay in the distributed file, and the /*! mark is the common way to say so. Turn off Keep license comments if you do not need them.

Does it minify SCSS or Less?

No. It reads plain CSS. A // comment in SCSS or Less is not a CSS comment, so compile to CSS first.

Why did I get an error instead of a result?

An unclosed comment, string or url( means the rest of the file cannot be read reliably, so no result is produced. The message gives the line and column. Other problems, such as an unclosed brace, are listed as notes and the result is still produced.

Is my CSS uploaded?

No. The minifier runs in your browser tab. Your styles are never sent anywhere.