CSS Formatter
Format CSS with consistent indentation and line breaks for braces and declarations.
How to Use
- Paste or type your text into the CSS Formatter input area above.
- Configure any format or mode options to generate the result in real time.
- Click Copy to copy the formatted result to your clipboard, or Reset to clear the workbench.
What is CSS Formatter?
The CSS Formatter is a client-side code beautifier that turns minified or inconsistently indented stylesheets into readable, structured CSS. Developers use it to inspect compressed production bundles, clean up pasted snippets, and standardize two-space indentation before code review.
How It Works
The custom formatCss scanner in _shared/css-format.ts walks characters one by one while tracking quoted strings and /* ... */ comments verbatim. It inserts newlines and two-space indentation on braces and semicolons, appends missing semicolons before closing braces, and adds spaces after declaration colons without corrupting :hover or ::before selectors.
Common Use Cases
- Reading minified third-party CSS — paste single-line production rules to expand braces, properties, and nested blocks cleanly
- Normalizing mixed-indentation stylesheets — standardize pasted styles to consistent 2-space blocks before committing
- Preserving pseudo-classes and strings safely — format CSS containing data URIs, content strings, and ::before selectors without breakage
- Fixing missing trailing semicolons — automatically insert a semicolon before closing '}' when the last property omits one
Technical Details
Zero-dependency character scanner (formatCss). Preserves single/double-quoted strings (with backslash escapes) and /* ... */ comments, indents with 2 spaces, guards pseudo-classes (:hover/::before), and never throws on malformed CSS.
FAQ
Is this CSS Formatter free?
Yes, completely free. No signup required.
Does this tool upload my data?
No. All processing happens locally in your browser. Your data never leaves your device.