Skip to content

CSS Formatter

Developer Tools•Client-Side & Private

Beautify minified or messy CSS — rules, selectors and declarations on clean lines, media queries indented, comments preserved, with 2- or 4-space indent.

Tool workspace

Loading tool controls…

Files processed locally — never uploaded to our servers
Free Instant Private

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

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.

1

Paste CSS

Paste minified or messy CSS, or load the sample.

2

Pick an Indent

Choose 2 or 4 spaces. Formatting updates live as you type.

3

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

Reading Minified StylesheetsTurn a one-line .css file into readable rules.
Cleaning Up Pasted CSSFix indentation on CSS copied from a tutorial or a chat.
Reviewing Media QueriesSee the responsive rules nested clearly inside each @media block.
Fixing a Stylesheet Before a ReviewBeautify a stylesheet so a reviewer can read it — pseudo-classes like a:hover stay intact, and a missing final semicolon is added.
📐

CSS Formatter - Block Indent and Declaration Lines

Formula Equation:
One declaration per line; indent level +1 after { and −1 at }; a colon is a declaration separator only after a bare property name

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

  1. 1Paste .card{margin:0 auto;padding:24px}/* Mobile layout */@media (max-width:640px){.card{padding:16px}.card h1{font-size:22px}}
  2. 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

Frequently Asked Questions about CSS Formatter

Frequently asked questions

Like any other block: @media (max-width: 640px) { opens a block, its rules indent one level inside, and the closing brace returns to the outer level. Nested rules indent further.

Yes. Block comments are kept whole and placed on their own line at the current indent.

They are never treated as declaration separators. The scanner tracks strings, comments and parentheses, so a colon or semicolon inside url(data:...;base64,...) stays part of the value.

Yes — 2 or 4 spaces. The formatted output is downloadable as a .css file.

No. Formatting runs entirely in your browser. Your code never leaves your device.

Yes. A declaration without a trailing semicolon gets one when its rule closes, so .a{color:red} becomes color: red; — the output stays consistent even when the input omits it.

Selectors are never split at their colon: a:hover, .card:hover and a::before stay intact, because a colon is only treated as a declaration separator inside a rule block after a bare property name. Colons inside url(), strings and comments are never separators either.

Complementary utilities for your workflow

View all →
You are here

CSS Formatter

Beautify CSS with clean rules and indentation.

Current tool

CSS Minifier

Minify and compress CSS for faster page loads.

Try tool

HTML Minifier

Minify HTML and reduce file size with one click.

Try tool

XML Formatter

Pretty-print, minify and validate XML, with a tree view.

Try tool