CSS Formatter

Format CSS stylesheets.

FreeNo accountOn your device

Runs in your browser. How to verify

Loading tool…

About this tool

Paste compact CSS and get one declaration per line with each block opened and closed on its own line. It is a simple text-based formatter for quickly making minified CSS readable.

How to use

1
Step 1
Paste your CSS.
2
Step 2
Press Run.
3
Step 3
Copy the formatted CSS.

How it works

The formatter inserts a line break after each opening brace, semicolon and closing brace, and indents declarations by two spaces. It works on the text and does not parse CSS, so it does not add or remove spaces inside declarations.

Worked example

Compact rules

Input
a{color:red;margin:0 auto}.b>p{font-size:12px}
Output
a { color: red; margin: 0 auto; } .b>p { font-size: 12px; }
Walkthrough
Each rule is split across lines. The spacing inside the declarations (color:red) is left as typed.

Limitations

  • Each declaration goes on its own line with a space after the colon, a final semicolon is added, and nested blocks such as @media are indented.
  • Comments are removed. It does not sort properties or reformat selectors beyond spacing after commas.

Questions

How do I format minified CSS?
Paste it and press Run. Each declaration goes on its own line.
Does it handle @media queries?
It breaks the lines, but the nested rules are not indented correctly.
Will it change my CSS?
Only the whitespace and line breaks change, but semicolons inside strings can be split.
Is there a CSS minifier too?
Yes, see the CSS minifier tool.

Features

  • One declaration per line
  • Two-space indent
  • Runs in your browser

Related resources

Guides and videos from around the web—opens on YouTube or the publisher’s site.

  • CSS Flexbox Crash Course

    freeCodeCamp.org

    Pretty-printed CSS helps when learning layout snippets.

    Watch on YouTube
  • SQL Tutorial - Full Database Course

    freeCodeCamp.org

    SQL formatters shine when reviewing long beginner queries.

    Watch on YouTube
  • CSS

    MDN

    CSS reference for reading beautified stylesheets after a format pass.

  • Prettier documentation

    Prettier

    Industry-standard formatting rules—compare with quick browser formatters.