About CSS Formatter
Paste a stylesheet, however cramped or untidy, and get it back laid out the same way every time: each rule on its own lines, one declaration per line, and nested @media, @supports and @layer blocks indented by level. Choose two spaces, four spaces or tabs.
Switch the mode to Minify when you need the opposite: comments and whitespace are removed and the size saved is shown. Formatting uses Prettier and minifying uses csso, both running in this tab.
How it works
- Your CSS is parsed with Prettier’s PostCSS-based parser and printed again with its standard layout, at the indentation you choose.
- Values, strings, selectors and comments are kept; what changes is the spacing, the line breaks and small details of notation such as quotes and leading zeros.
- In Minify mode csso parses the stylesheet, drops whitespace and ordinary comments, shortens values where the result is identical, and can merge rules that share selectors or declarations.
- The work runs in a background worker, so a large stylesheet never freezes the page.
Questions
What happens if my CSS has a syntax error?
Nothing is guessed. The tool stops and names the line and column where the parser gave up, such as an unexpected closing brace, so you can fix it at the source.
Does it work with SCSS or Less?
Plain CSS is what it is built for. SCSS or Less that is also valid CSS syntax, such as nested rules, usually formats fine, but mixins and other preprocessor-only syntax may be rejected.
Is anything uploaded?
No. Prettier and csso are loaded into this page the first time you use them and run on your device. Your stylesheet is never sent anywhere.
How large a stylesheet can it handle?
Up to 2 MB of text. Larger input is turned away with a message before anything is processed.
Everything you enter here is processed in this browser tab. Nothing is uploaded, logged or shared. How privacy works here.