Skip to content

CSS Formatter & Minifier - Format or Minify CSS Online

CSS input

Format or minify CSS

Paste CSS and choose Format or Minify. Format puts each declaration on its own line, indents rules inside @media and other at-rules, and adds a blank line between rules. Minify strips comments and whitespace. The original and output sizes appear under the editor.

Example

Minifying

.card {
  color : red ;
  margin: 0 0 0 0;
}
/* unused */
.badge {}

gives .card{color:red;margin:0 0 0 0}.badge{}.

Note what it does not do: 0 0 0 0 is not shortened to 0, empty rules are kept, and colours are not rewritten. That is whitespace and comment removal only. For a production build, a minifier such as cssnano or Lightning CSS in your bundler does those extra rewrites.

Strings and url() values are copied as they are in both modes. To tidy markup, use the HTML formatter.

Related Tools

Frequently Asked Questions

What does the formatter change?
Only whitespace. Each declaration goes on its own line with two-space indentation, a space follows each colon, and rules are separated by a blank line. Selectors, values and property order are left alone.
What does minify remove?
Comments, line breaks and spaces that CSS does not need, including the last semicolon in each rule. It does not merge rules, shorten values or drop empty rules, so a file already run through a build tool will not get much smaller.
Are comments kept?
When formatting, yes, each on its own line. When minifying, all comments are removed, including /*! licence comments. Add those back by hand if your licence requires them.
Is my CSS sent anywhere?
No. Formatting and minifying both run in your browser.