CSS beautifier

Paste minified or messy CSS and get clean, indented code with one declaration per line. Choose 2 spaces, 4 spaces or tabs. It is free and your code never leaves your browser.

How to use it

  1. Paste your CSS in the Your CSS box.
  2. Pick your style in Indentation: 2 spaces, 4 spaces or Tab.
  3. Click Copy or Download to use the Formatted CSS.

Complete guide to formatting CSS

Why format CSS at all

Browsers do not care whether a stylesheet is one long line or nicely indented, but people do. Production files are usually minified, and a quick fix on a live site often starts with opening a file where every rule sits on the same line. A CSS beautifier restores the structure: one selector per line, one declaration per line, and indentation that shows which rules sit inside a media query. It is also handy for cleaning up CSS pasted from a chat, a forum or a generator.

What the tool changes and what it leaves alone

It only changes whitespace. Selectors, property names, values, strings and comments keep their content. Specifically, it:

  • puts every declaration on its own line, ending in a semicolon;
  • writes a space after the colon and after commas in values, so rgba(0,0,0,.2) becomes rgba(0, 0, 0, .2);
  • puts each selector of a comma list on its own line;
  • puts spaces around the combinators >, + and ~ in selectors;
  • indents the contents of @media, @supports and other blocks one level deeper;
  • leaves a blank line after each top-level block;
  • keeps quoted strings, comments and unquoted url() values (including data URIs) exactly as written.

It does not sort properties, add missing zeros, fix errors or check that the CSS is valid. Nothing is uploaded: the formatting runs in your browser.

Worked example

  1. Paste this into Your CSS: .card{display:flex;padding:16px 24px}.card:hover,.card:focus{box-shadow:0 2px 8px rgba(0,0,0,.2)}@media (max-width:600px){.card{display:block}}
  2. Leave Indentation on 2 spaces.
  3. The Formatted CSS comes out as:

.card {
  display: flex;
  padding: 16px 24px;
}

.card:hover,
.card:focus {
  box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
}

@media (max-width: 600px) {
  .card {
    display: block;
  }
}

Choosing Tab uses one tab character per level instead, which is what many teams and editors expect. The 4 spaces option is common in projects that follow older style guides.

Tips and common mistakes

  • If the output looks wrong, look for a missing brace or semicolon in the original. The tool does not report syntax errors, so broken input can produce odd indentation, much like in an editor.
  • A beautifier is for reading and editing. Before publishing, minify the result again with the CSS minifier to reduce the file size.
  • Formatting a file before a code review makes the real changes easier to spot, but do it in a separate commit so the diff does not mix style and substance.
  • Keep your team's convention: pick 2 spaces, 4 spaces or tabs once and use it everywhere.
  • Use the Download button to save the result as a styles.css file instead of copying it by hand, which is handy for long stylesheets.

Related tools

When you are converting design values while editing, the px to rem converter and the color converter help. To format other code, see the HTML beautifier.

Questions

Does it change what my CSS does?

No. It only changes spacing and line breaks. Selectors, values, strings and comments keep their content.

Can it format minified CSS?

Yes. That is the most common use: paste a .min.css file and get readable code back, with each selector and declaration on its own line.

How are selector lists and media queries handled?

Each selector in a comma list goes on its own line, and rules inside @media or @supports blocks are indented one more level.

Is my CSS uploaded anywhere?

No. The formatting runs in your browser and nothing is sent or stored.