CSS Formatter

Beautify minified or cramped CSS — one declaration per line, braces and blank lines tidied — right in your browser. A fast regex tidier, not a full parser.

Developer Tools Free No upload Instant

Loading CSS Formatter…

Your browser is preparing the tool. It runs 100% locally.

Quick Answer

Paste minified or cramped CSS and the tool lays it out cleanly: the opening brace on the selector line, each declaration on its own indented line, the closing brace on its own line, and a blank line between rules. It is a lightweight regex tidier — it does not parse the CSS — so it does not validate the code or add a space after each colon. It runs entirely in your browser; nothing is uploaded.

What the CSS Formatter Does

This tool takes CSS that has been minified or jammed together and reformats it into the conventional, readable layout: selector and opening brace, then one property-and-value per line indented two spaces, then the closing brace, with rules separated by a blank line.

It is the quick way to make a compressed stylesheet legible — to inspect what a build tool produced, read a copied rule, or tidy a snippet before pasting it into your project.

How It Works

The tool runs a series of regular expressions over the text. It puts a space and a line break around each opening brace, a line break after every semicolon, and the closing brace on its own line followed by a blank line. Declarations end up indented two spaces.

Because it works purely on the braces, semicolons and surrounding whitespace, it is fast and needs no dependencies. It is not a CSS parser, though: it does not understand selectors, properties or values, so it cannot validate the code or reason about structure beyond those punctuation marks.

Processing pipeline

  1. Break around braces. Put a space before each opening brace and a line break after it, and place each closing brace on its own line.
  2. One declaration per line. Add a line break after every semicolon so each property sits on its own line.
  3. Indent declarations. Indent the lines inside a rule by two spaces.
  4. Separate the rules. Add a blank line after each closing brace, then trim stray whitespace.

How it reformats

selector + opening brace → same line, then a line break after every semicolon → a new line closing brace → its own line, then a blank line declarations → indented two spaces
Worked example
Before: body{margin:0;padding:10px} After: body { margin:0; padding:10px }

It breaks lines around the punctuation but does not add a space after the colon, so margin:0 stays as-is. It also indents every declaration exactly two spaces, so nested at-rules like a media query are not indented an extra level.

Privacy

Your CSS never leaves your device. It is reformatted in your browser with no network request, so nothing is uploaded.

Because the work is local, you can tidy proprietary or unreleased styles without them being stored or sent anywhere.

Nothing persists between sessions — close the tab and the input and output are gone.

Standards & references

  • CSS syntax — CSS rules are a selector followed by a brace-enclosed block of property and value declarations separated by semicolons. The tool keys off those braces and semicolons rather than parsing the grammar.
  • At-rules — Rules like a media query wrap other rules in another brace block. Because the tool indents every declaration by a fixed two spaces, it does not nest the inner rules one level deeper.
  • Parser-based formatters — Tools like Prettier or stylelint parse the stylesheet into a tree and reprint it, so they can validate, nest correctly and give idempotent output. This tool is a lighter regex tidier.

Accuracy & Limitations

It produces the conventional layout for ordinary rules, but it is a regex tidier, not a parser. It does not validate the CSS or check that braces balance — it only reflows around the punctuation, so malformed input yields malformed output.

It does not add a space after the colon in a declaration, so a property reads as margin:0 rather than margin: 0. The value is correct; only the cosmetic spacing differs from what a full formatter would produce.

At-rules are not nested. Because every declaration is indented exactly two spaces, the rules inside a media query or supports block sit at the same indent as a top-level declaration rather than one level deeper.

A semicolon or brace inside a string or a comment can trigger an unwanted line break, since the tool reacts to those characters without understanding that they are quoted or commented out. A parser would ignore them.

Real-World Use Cases

Reading minified CSS

Expand a compressed stylesheet into readable rules.

Tidying a snippet

Clean up a copied rule before adding it to your project.

Reviewing a build output

See what a bundler produced in a legible layout.

Teaching and notes

Present CSS clearly in documentation.

When to use it — and when not to

Good for

  • Reading minified or cramped CSS
  • Laying out a rule one declaration per line
  • Tidying a snippet for review
  • A fast, no-install beautify

Not the best choice for

  • Validating or linting the CSS
  • Correctly nesting at-rules like media queries
  • Style with semicolons inside strings or comments
  • A guaranteed idempotent reformat

For a parser-based reformat that validates and nests correctly, use Prettier or stylelint in your editor. This tool is for a quick in-browser tidy of a snippet, not production linting.

Frequently Asked Questions

Does it validate my CSS?
No. It only reflows the text around braces and semicolons. It does not check that properties or values are valid, so broken CSS comes out broken. For linting, use a tool like stylelint.
Why is there no space after the colon?
The tool breaks lines around the punctuation but does not insert a space after the colon, so a declaration reads as margin:0. The value is unchanged; it is purely a cosmetic difference from a full formatter.
Does it indent media queries correctly?
Not as nested blocks. It indents every declaration by a fixed two spaces, so the rules inside a media query sit at the same indent as a top-level declaration rather than one level deeper.
Is it a real CSS parser?
No. It uses regular expressions keyed off braces, semicolons and whitespace. It does not understand selectors, properties or values, which is why it is fast but limited.
Will a comment break the formatting?
It can. A semicolon or brace inside a comment or a string can trigger an unwanted line break, because the tool reacts to those characters without knowing they are quoted or commented. A parser would skip them.
Does it minify CSS as well?
No, this tool expands and indents. To strip whitespace and compress, use a CSS minifier.
Is my CSS uploaded?
No. It is formatted entirely in your browser. Nothing is sent to a server, so private styles stay on your device.
How much does it indent?
Two spaces for each declaration inside a rule. The selector and braces sit at the left margin.
Can it handle a whole stylesheet?
You can paste a full stylesheet in. For large or nested files, a parser-based formatter handles at-rules and edge cases more reliably.
Why did a second run change the spacing?
It is not guaranteed idempotent, because it reacts to the current whitespace rather than rebuilding from a parsed tree. A parser-based formatter gives the same result every time.
Does it work offline?
Yes. After the page loads, formatting runs locally with no further network access.
Should I use this or Prettier?
For a quick in-browser look at a snippet, this is convenient. For a codebase or anything that must be consistent and valid, a parser-based formatter like Prettier is the better choice.

References

Re-indents with a regex that breaks around braces and semicolons; honest that it does not parse the CSS, so it does not validate, add a space after the colon, or nest at-rules deeper.

PopularHot

JSON Formatter

JSON Formatter for developers — instant, offline-style and privacy-safe.

DeveloperOpen Tool
Popular

JSON Validator

JSON Validator for developers — instant, offline-style and privacy-safe.

DeveloperOpen Tool
Popular

Base64 Encoder

Base64 Encoder for developers — instant, offline-style and privacy-safe.

DeveloperOpen Tool
Popular

Hash Generator

Fast, free Hash Generator that runs entirely client-side in your browser.

DeveloperOpen Tool
Popular

UUID Generator

Fast, free UUID Generator that runs entirely client-side in your browser.

DeveloperOpen Tool
Trending

CSS Minifier

Fast, free CSS Minifier that runs entirely client-side in your browser.

DeveloperOpen Tool

Ready to try the CSS Formatter?

It is free, private and runs entirely in your browser — no sign-up, no uploads, no limits.