CSS Minifier
WM-17Paste CSS to strip its comments and extra whitespace. The Size saved button shows how many bytes you gained, and the rules stay in the same order.
Runs in your browser. Nothing is uploaded.
CSS
Minified CSS
How to use it
- Paste your CSS into the input box, or open a .css file (up to 5 MB).
- Leave Keep /*! license */ comments ticked if your stylesheet carries a license notice, or untick it to remove those too.
- Choose Minify, then copy or download the result.
- Choose Size saved to see the before and after size in bytes.
What gets removed
Comments, line breaks, indentation and the spaces around braces, colons, semicolons and commas are removed, and the last semicolon in each block is dropped. A space is kept where removing it would join two tokens, such as between the parts of a shorthand like margin: 0 auto or around a descendant selector. Strings and unquoted url() values are copied exactly as written, and escaped characters in a selector are left alone.
What it does not do
This is a whitespace and comment minifier. It does not reorder rules, merge duplicate selectors, shorten colors such as #ffffff, drop units, rename anything or remove unused CSS. That is deliberate: those steps can change how the cascade behaves. The saving is therefore modest. A server that serves gzip or Brotli compresses the file further, and this tool does not measure that.
Keeping license comments
Comments that start with /*! are usually license or attribution notices. They are kept by default so you stay within a library's terms. Untick the option if you want every comment gone. Either way, the check for unclosed comments, strings and braces runs first, and you get the line number of the problem.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
Comment starting at line 3 is never closed (missing */). | A /* comment has no matching */, so the rest of the file would be swallowed by it. | Add the closing */ or delete the unfinished comment. |
String starting at line 7 is never closed (missing "). | A quoted string reaches the end of its line without a closing quote. | Add the missing quote, or escape the line break inside the string with a backslash. |
1 block opened with { and never closed (missing }). | There are more opening braces than closing braces. | Find the rule that is missing its } and add it. |
Unexpected } at line 12 with no matching {. | A closing brace appears with nothing open. | Remove the extra } or add the opening { it belongs to. |
Questions people ask
How do I minify CSS?
Paste the stylesheet, choose Minify and copy the result. Comments and whitespace are removed and rules stay in their original order. Use Size saved to see how many bytes you gained.
Will minifying CSS break my styles?
It should not. Only comments and whitespace that cannot affect parsing are removed, and strings, url() values and escapes are kept as written. Because rules are not merged or reordered, the cascade is unchanged. Still, test the page after you deploy a new build.
Does it remove unused CSS?
No. Finding unused rules needs the HTML and scripts that use them, which this page never sees. A tool such as PurgeCSS, run in your build, does that job. This page only shrinks the text of the stylesheet you paste.
Why is my file only a little smaller?
Whitespace and comments are a limited share of most stylesheets. If your CSS was already compact, there is little left to remove. Gzip or Brotli on your server will usually give a bigger saving than minifying alone.
Are /*! comments kept?
Yes by default, because they usually hold license text. Untick Keep /*! license */ comments to remove them as well. All other comments are removed in both cases.
Can I get the original back?
No, minifying is one way. Keep your readable source file and minify a copy for production. If you only have the minified file, the CSS Formatter on this site can lay it out again, but the removed comments are gone.
About this tool
Removes comments and the whitespace that cannot matter, and drops the last semicolon in each block. Strings and url() values are kept exactly as written, and escaped characters in selectors are left alone. It does not reorder, merge or rename rules, shorten colors or numbers, or remove unused CSS, so the savings are smaller than a tool that optimizes. Comments that start /*! are kept unless you turn that off. Unclosed strings, comments and braces are reported with a line number. "Size saved" compares UTF-8 byte counts before and after; a server that gzips files will shrink them further, and this tool does not measure that.