CSS Formatter

Paste minified or badly formatted CSS and get it back readable: one declaration per line, properly indented, with nested media and supports queries stepped in so the structure is visible at a glance. The formatter handles the detail that catches most beautifiers out — minified CSS drops the semicolon after the last declaration in a rule, so a naive formatter leaves the closing brace glued to it as 'margin: 0}'. Here the semicolon is restored and the brace gets its own line. Selector lists can be split one per line, indentation is configurable, and comments survive. There is a minify direction too, so you can go both ways. It all runs in your browser, so unreleased stylesheets stay on your machine.

What the formatter does to each construct

InputOutput
.a{color:red}.a {\n color: red;\n}
.a{margin:0}Semicolon restored before the closing brace
@media(...){.a{...}}Contents indented one level inside the query
.a,.b{...}Optionally one selector per line
font-family:a,bCommas inside a value stay on one line
/* comment */Preserved, on its own line

When to use it

  1. Make a minified stylesheet readable so you can find a rule in it.
  2. Reformat CSS copied out of devtools or a build output.
  3. Standardise indentation before committing a stylesheet.
  4. Inspect what a framework's compiled CSS actually contains.
  5. Compress a stylesheet back down after editing it.

How to Use

  1. Paste your CSS, minified or otherwise.
  2. Choose indent size, brace style and whether to split selector lists.
  3. Read the formatted output, or flip to minify to go the other way.
  4. Copy or download the result.

Features

  1. One declaration per line with configurable indentation
  2. Nested at-rules indented by brace depth
  3. Closing brace on its own line, missing semicolon restored
  4. Optional one-selector-per-line splitting
  5. Comments preserved, not collapsed
  6. Minify direction included
  7. 100% client-side — unreleased stylesheets stay private

FAQs

Will formatting change how my CSS behaves?

No. Only whitespace and line breaks change, plus a semicolon restored after a final declaration — which is optional in CSS and has no effect on rendering. Selectors, properties and values are untouched.

Does it handle media queries and nesting?

Yes. Brace depth is tracked, so the contents of a media or supports query indent one level inside it, and further nesting steps in again. That is what makes a long compiled stylesheet readable.

What happens to comments?

They are preserved and placed on their own line. Comments are stashed before the whitespace normalisation so their contents cannot be collapsed, which is how a formatter can otherwise mangle a licence header.

Does it support SCSS or Less?

Partly. Plain nesting will indent correctly because it is brace-based, but preprocessor-specific syntax — mixins, variables with interpolation, control directives — is not understood and may not come out as you would want. Use your preprocessor's own formatter for source files.

What is the difference between this and the CSS Minifier?

They share the same engine. This page is focused on making CSS readable; the minifier is focused on making it small and adds compression levels, duplicate merging, batch files and analysis. Use whichever matches what you are actually doing.

Is my CSS uploaded?

No. Formatting happens in your browser. Unreleased stylesheets and proprietary design systems are never sent to a server, logged, or stored.

Technical Details

The stylesheet is normalised before it is rebuilt: comments are stashed so the whitespace collapse cannot touch them, all runs of whitespace become single spaces, and the spacing around braces, semicolons, colons and commas is stripped, giving a canonical form regardless of how the input was written. The formatter then walks that string character by character, tracking brace depth so nested at-rules such as media and supports queries indent their contents, and tracking whether it is inside a declaration value so a colon in a property separates the name from the value while a colon in a pseudo-selector does not. The closing brace is emitted on its own line, and a final declaration with no trailing semicolon has one added — minified CSS omits that semicolon, and without the fix the brace ends up glued to the declaration as 'margin: 0}'. Selector lists optionally break onto one line per selector. The same engine backs the Beautify tab of the CSS Minifier, so the two cannot drift apart.

Developer Tools

Developer Tools

  • HTML Formatter
  • LLM Token Counter
  • .gitignore Generator
  • Dummy Data Generator
  • RAID Calculator
  • Download Time Calculator
  • JSON Formatter
  • JSON Validator