CSS Formatter
Beautify minified or messy CSS into readable code with one declaration per line, clean indentation, nested at-rules and optional one selector per line.
Reviewed 23 November 2026 · Free · No account needed
How to use
- Paste your CSS on the left, or press Example to try a sample.
- Choose 2 spaces, 4 spaces or a tab for the indent.
- Turn on One selector per line to split comma separated selectors, and Blank line between rules for easier scanning.
- Copy the formatted result or download it as formatted.css.
Example
Input: .card,.panel>.title{margin:0 auto;padding:8px 16px}
Output: .card, .panel > .title { margin: 0 auto; padding: 8px 16px; }
How it works
A small tokenizer reads the stylesheet one character at a time and tracks whether it is inside a string, a comment, a url(...) value or a block. It splits the code into rule openings, declarations and closings, and writes them back with the indentation and spacing you chose.
Each block opens at a left brace and closes at a right brace. Indent depth = number of open blocks. Every declaration ends with a semicolon and goes on its own line. Selector lists split at commas outside brackets and strings.
The input @media (max-width:600px){.card{padding:8px}} becomes an @media (max-width: 600px) line, then an indented .card rule, then a closing brace for each level, with each declaration indented one more step than its selector.
Limits and edge cases
- The formatter changes layout only. It does not validate CSS, reorder properties, add vendor prefixes or fix typos.
- Preprocessor syntax such as SCSS mixins or Less guards is not understood. Plain nested rules and at-rules are handled.
- Unbalanced braces and unterminated strings or comments are reported as warnings, and the output may need manual repair.
- Very large stylesheets of several megabytes can make the page slow, because formatting runs in the browser tab.
- A semicolon, brace or comma inside a quoted string or a url(...) value is left alone, so content: "; }" stays intact.
- Comments are kept exactly as written and placed on their own line at the current indent.
- Selectors inside :is(...), :not(...) or attribute brackets keep their commas, so only top level commas split a selector list.
- Top level @charset and @import lines are not followed by a blank line, so they stay grouped at the top of the file.
Privacy
Your stylesheet is formatted by your browser on this device. The code is never uploaded, stored or sent anywhere.
About this page
Written and reviewed by Toolnexo on 23 November 2026. The limits above describe the published tool, not an idealised version of it. If a result looks wrong or the page is unclear, email [email protected] with the tool URL and what you entered. Corrections are published here.
Guides that use CSS Formatter
Related tools
Questions about CSS Formatter
How do I format minified CSS?
Paste the minified code into the box and the readable version appears at once. Choose your indent, copy the result or download it as a .css file.
Does formatting change how my CSS works?
No. Only spaces, line breaks and indentation change, and browsers ignore them. Values, strings, comments and url(...) contents are kept exactly as you wrote them.
Can it format media queries and nested rules?
Yes. @media, @supports, @layer and other at-rules are indented, and so are native CSS nesting blocks inside a rule.
Does it support SCSS or Less?
It formats plain CSS and native nesting. SCSS and Less features such as mixins, variables with a dollar sign and guards are not parsed, so use a preprocessor aware formatter for those files.
What is the difference between this and the CSS minifier?
They are opposites. The formatter adds spacing and line breaks so people can read the code, and the CSS minifier removes them so the file is smaller to send. Format to read and edit, minify to ship.
Is my code uploaded?
No. The stylesheet is formatted entirely in your browser and never leaves your device.