CSS Formatter
Beautify minified or messy CSS — rules, selectors and declarations on clean lines, media queries indented, comments preserved, with 2- or 4-space indent.
Loading tool controls…
Verify it yourself: press F12, open the Network tab, and use this tool — your files are never uploaded.
CSS Formatter at a glance
- Price
- Free
- Account
- Not required
- File uploads
- None — your files are never uploaded
- Category
- Developer Tools
Who uses Developer Tools?
Developers and engineers formatting JSON, testing regex, hashing data, encoding values or building API requests.
How to Use CSS Formatter
Follow these simple steps to get instant results in your browser.
Paste CSS
Paste minified or messy CSS, or load the sample.
Pick an Indent
Choose 2 or 4 spaces. Formatting updates live as you type.
Copy or Download
Copy the formatted CSS or download it as formatted.css.
What is CSS Formatter & How Does It Work?
CSS Formatter beautifies minified or messy CSS: rules, selectors and declarations on clean lines, media queries indented like any other block, and comments preserved — at 2 or 4 spaces, downloadable as a .css file.
The scanner is string-, comment- and parenthesis-aware. A semicolon or colon inside a string, a comment or parentheses never splits a declaration — so url(data:...;base64,...) survives intact, and a selector such as a:hover or .card:hover inside a media query is never mistaken for a declaration.
Comments are kept whole on their own line at the current indent. The formatter changes layout only: selectors, properties, values and their order are never altered.
Key Features & Capabilities
Clean Rule Layout
One declaration per line, selectors on their own line, braces aligned.
Media Queries Indented
@media blocks indent like any other block, with their rules nested inside.
Comments Preserved
Block comments are kept whole on their own line.
url() and Data URI Safe
Colons and semicolons inside url() or strings never split a declaration.
Private by Design
Formatting runs entirely in your browser — nothing is uploaded.
Pro Tips
- •Bookmark this tool for instant one-click access anytime.
- •Drag and drop files directly onto the input surface for fastest handling.
- •All processing happens in your browser session for maximum speed and data safety.
🎯 Common Use Cases
CSS Formatter - Block Indent and Declaration Lines
The CSS is scanned character by character with string, comment and parenthesis tracking. An opening brace starts a block at one deeper indent, a closing brace ends it, and a semicolon outside parentheses ends a declaration line. A colon counts as a declaration separator only when the text built so far is a bare property name — selectors such as a:hover never match, so they are left untouched.
Worked Example
- 1Paste .card{margin:0 auto;padding:24px}/* Mobile layout */@media (max-width:640px){.card{padding:16px}.card h1{font-size:22px}}
- 2Formatted (2 spaces): .card { with margin and padding on their own indented lines, the comment on its own line, then @media (max-width:640px) { with both rules indented inside it
Sources & Further Reading
- CSS: Cascading Style Sheets — MDN
- CSS Snapshot 2023 — W3C
Frequently Asked Questions about CSS Formatter
Frequently asked questions
More Developer Tools
Complementary utilities for your workflow
CSS Formatter
Beautify CSS with clean rules and indentation.