CSS Formatter
Format CSS stylesheets.
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
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?
Does it handle @media queries?
Will it change my CSS?
Is there a CSS minifier too?
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 YouTubeSQL 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.