Tools / CSS Formatter & Minifier

CSS Formatter & Minifier.

Beautify CSS with one declaration per line or minify it safely, including nested rules and media queries.

Runs in your browser

Ctrl/⌘ + Enter to run · Ctrl/⌘ + Shift + C to copy the result

Result
Result
Stats

About CSS Formatter & Minifier

The CSS Formatter turns a minified or messy stylesheet into something you can read and review: one selector per line, one declaration per line, a space after each colon and comma, and consistent indentation for media queries, @supports blocks and native CSS nesting. Minify mode goes the other way and removes comments, line breaks and every space that the CSS grammar does not need, which is usually the largest saving before gzip. Minifying CSS by hand is easy to get wrong, so the tool only removes whitespace in places where it cannot change meaning. The descendant space in "a :hover" is kept because it selects something different from "a:hover". The spaces around + and - inside calc() are kept because calc(100% -2rem) is invalid. Strings, url() values and custom property values are left alone, and no values are rewritten: 0px stays 0px and colours keep their case. Before a result is shown, it is tokenised again and compared with the input, so a formatting bug produces an error message rather than a broken stylesheet. For example, ".card>.title+p{margin:0}" formats to ".card > .title + p" with the declaration on its own indented line, and minifies back to the original. Common mistakes it reports with a line and column are an unclosed block (a missing closing brace), an unterminated string in a content property and an unclosed comment. License comments that start with /*! are kept when minifying unless you switch that off. Your CSS stays in your browser.

How to Use

  1. Paste your stylesheet into the CSS field.
  2. Choose Format or Minify; pick the indentation for formatted output.
  3. Copy or download the result.

Frequently Asked Questions

Does minifying change any values?

No. The minifier only removes comments and unnecessary whitespace and drops the last semicolon in each block. It does not shorten colours, units or property names, so the output behaves exactly like the input.

Does it support SCSS or Less?

It handles plain CSS including native nesting (&:hover inside a rule). SCSS and Less files without their own syntax (variables, mixins, // comments) usually format fine, but // line comments are not understood.

Why did I get "could not reproduce this stylesheet"?

Every result is re-checked against the input. If the check fails the tool refuses to output anything rather than risk changing your CSS. Please report the input so the case can be fixed.

Is the stylesheet uploaded?

No. It is processed in your browser and never leaves your device.

Related Tools