b2KIT

CSS Beautifier

Format and beautify minified CSS code with configurable indentation, brace placement, and property sorting.

Tested tool guide Tested browser tools Checked August 16, 2026

What CSS Beautifier does, with a checked example

Paste a minified stylesheet - one line, thousands of characters - and get the same rules back one declaration per line, with indentation that mirrors the nesting of media queries and other at-rules. The output is produced by re-emitting the input with whitespace added only at structural boundaries, so with the layout settings alone the formatted CSS is equivalent to the source. The option users most often misjudge is property sorting: it reorders declarations, and CSS applies the last matching declaration, so sorted output can render differently from the input.

Worked example

A concrete input and expected output from the current implementation.

Input

.btn{display:inline-block;padding:8px 16px;color:#fff;}.btn:hover{color:#ff0;}

Expected output

.btn {
  display: inline-block;
  padding: 8px 16px;
  color: #fff;
}
.btn:hover {
  color: #ff0;
}

Each declaration moved to its own line with a two-space indent, and the closing brace returned to the margin. The declaration colons gained a space after them, while :hover stayed attached to .btn - that colon is part of the selector, and adding a space there would break the rule.

How the result is produced

1

Line breaking at structural tokens

The input is walked token by token: a newline plus one indent step goes after every {, a newline after every ;, and a dedent before every }. Property names, values, units, comments, and selector text pass through unchanged, with only the spacing around declaration colons adjusted. Indent depth follows nesting, so an at-rule like @media visibly contains its rules.

2

The three settings

Indentation width controls the step added per nesting level. Brace placement moves the opening brace between the end of the selector line and its own line. Property sorting is a separate switch that alphabetizes declarations within each rule; it does not touch selectors or at-rules, and it applies independently of the other two settings.

Good uses

  • Reading a minified stylesheet from a build artifact, a CDN, or a paste out of browser dev tools, when you need to see what a specific rule actually sets.
  • Comparing two versions of a stylesheet: beautify both first so the diff shows real changes instead of one file being a single unreadable line.
  • Normalizing a project's CSS to one layout before review or commit, with sorting switched on to surface duplicate or conflicting declarations that the minified lines hid.

Limits and checks

  • Property sorting is not render-safe. CSS applies the last matching declaration, so a rule such as margin: 10px; margin-left: 0; computes differently once sorted, because margin lands after margin-left. Duplicate or overlapping declarations anywhere in the input are the red flag: keep sorting off when they exist.
  • Braces and semicolons inside string values, such as content: "}" or a url(data:...;base64,...) argument, look like structure to a tokenizer but are data. If the output comes out unbalanced or garbled around such a value, that is the likely cause, and no formatting step can repair it.
  • It is a formatter, not a validator. Invalid CSS passes through untouched, and the layout choices it makes - whether rules are separated by blank lines, whether a multi-selector rule stays on one line - may not match your team's conventions. Sample the output before trusting it wholesale.

Common questions

Does sorting properties alphabetically change how my page renders?

It can, and the failure is silent. Within a rule, CSS uses the last declaration that applies, so reordering matters whenever declarations overlap - margin: 10px; margin-left: 0 renders with a 0px left margin before sorting and a 10px one after. Sorting is only safe when no rule contains duplicate or overlapping declarations; if you cannot rule that out, leave sorting off.

Is the beautified CSS guaranteed to behave exactly like the minified original?

With sorting off and valid CSS as input, yes: the tool only inserts whitespace, and whitespace between tokens carries no meaning in CSS, so cascade and rendering are unchanged. With sorting on, no guarantee. And minification steps that already ran - merging duplicate selectors, dropping comments - cannot be undone, because that information is not present in the input.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools