DataToolsLab
Code Formatter Tools

CSS Formatter

Beautify minified or inconsistent CSS with configurable indent and brace style.

Loading tool…

What is CSS Formatter?

A CSS beautifier. It reads a stylesheet token by token and rewrites the layout: selectors and at-rule preludes on their own line, declarations indented inside their block, braces where you asked for them.

How it works

The tokenizer understands comments, strings, urls, at-rules and nested blocks, so it can indent by real block depth rather than by counting braces in a regex. Declarations are normalised to a single space after the colon and the semicolon is re-added where it was missing.

  1. Paste the source. Drop in code, a stylesheet, a query or a selector list. Everything is read locally — the page never uploads what you paste.
  2. Choose the options. Indent width, quote style, keyword case or target browsers. The result updates as you change them, so you can see the effect immediately.
  3. Copy or download. Copy the result to the clipboard or download it as a file. Reset clears the form and returns every option to its default.

Examples

A minified bundle → readable code

Beautifying a 40 KB one-line stylesheet or script turns it into something reviewable, without altering a single token of the program itself.

A query moved between databases

MySQL's backticks, AUTO_INCREMENT and LIMIT 10, 20 become PostgreSQL's double quotes, identity columns and OFFSET — with a list of what still needs a human.

A stylesheet that only breaks in Safari

backdrop-filter, user-select and position: sticky need -webkit- prefixes for older Safari, which the CSS Autoprefixer adds for exactly the targets you tick.

Common mistakes

Expecting a formatter to fix invalid code

Formatting is whitespace and quoting. A missing brace, an unclosed tag or an unquoted variable survives the round trip and is reported instead — check the findings list.

Minifying without running the tests afterwards

Even a safe, non-mangling minifier can expose an existing automatic-semicolon-insertion bug. The JavaScript Minifier keeps the newlines that matter, but re-run your tests before shipping.

Treating a rewritten query as verified

The SQL Dialect Converter translates the syntax it can prove; data types, casts and function differences are listed for review, not guessed. Run the converted query against a real database.

Renaming or reformatting generated files

Regenerating a formatter's output is a no-op only if the formatter is the same one that produced it. Keep generated code out of the round trip and format the source it came from.

Frequently asked questions

Does formatting change how the CSS applies?

No. Whitespace between declarations and around combinators is not significant, and this tool never reorders declarations or changes values — the cascade is untouched.

Does it handle SCSS or nested CSS?

Yes for the nesting syntax browsers now support and for @media/@supports blocks: indentation follows brace depth. Mixins, functions and @if blocks are laid out by the same rules, but preprocessor evaluation is out of scope.

What if my stylesheet has a syntax error?

The formatter keeps going: because it works from tokens rather than a parse tree, one bad declaration does not stop the rest of the file from being formatted.

Online