CSS formatter
Runs entirely in your browser. Your files and data never leave your device.
About this tool
Paste a CSS stylesheet or snippet and this tool will pretty-print it with consistent indentation, or compress it down to a single dense line. Malformed CSS with unclosed braces or dangling rules still gets formatted instead of throwing an error, so you can clean up rough CSS without fixing every syntax issue first.
How does formatting and minifying work?
Pretty-printing runs on the js-beautify library, which you can point at 2-space, 4-space, or tab indentation. It works on tokens rather than a strict parser, so a stylesheet with a missing closing brace or a stray semicolon still comes out reasonably indented instead of raising an error, which matters if you’re cleaning up CSS copied from a browser’s dev tools or a half-finished file. Minifying takes the opposite path: it strips comments, collapses whitespace, and removes unneeded spaces around { } ; : , >, while leaving the contents of quoted strings and url(...) calls untouched so a path or a font name with spaces in it survives intact.
The minifier is a set of regex passes rather than a full CSS parser, so it has a couple of known edge cases: a url() containing a literal closing parenthesis inside a quoted argument won’t be handled correctly, and collapsing space before a colon can join a descendant combinator with a following pseudo-class (turning a :hover into a:hover, which changes what the selector matches). Both are rare in real-world CSS, and the tool trades that small risk for never choking on rough input.
Is my CSS uploaded anywhere?
No. Formatting and minifying happen entirely in your browser using the bundled library, nothing is sent to a server. Proprietary stylesheets, client work, or scraped fragments with real content stay on your machine, which is useful when the CSS you’re cleaning up came from an internal codebase you’d rather not paste into a random web form.
Common uses: tidying up a minified stylesheet saved from view-source, shrinking a CSS file before shipping it, or reformatting a component’s styles to a consistent indent width for a code review. See the MDN CSS syntax reference for how selectors, declarations, and at-rules fit together.