Boneyard Tools

CSS Formatter and Beautifier

Paste minified or messy CSS and this tool pretty-prints it instantly with a small tokenizer, so strings, comments and url() contents are preserved exactly. Each selector and at-rule prelude gets its own line, declarations are indented one per line and end in a semicolon, and the space after each colon is normalized. Pick two spaces, four spaces or a tab, then copy the result or download it as a .css file.

How to format CSS

  1. Paste your CSS into the top box, or click Load sample to try it on an example.
  2. Choose an indent size with the toggle: 2 spaces, 4 spaces, or Tab.
  3. Read the beautified output in the Formatted CSS box below.
  4. Click Copy to grab the result, or Download to save it as formatted.css.

Examples

Beautify a minified rule

a{color:red;font-weight:bold}
a {
  color: red;
  font-weight: bold;
}

Nested media query

@media (max-width:600px){body{margin:0}}
@media (max-width:600px) {
  body {
    margin: 0;
  }
}

Grouped selectors get tidy commas

.a,.b{color:blue}
.a, .b {
  color: blue;
}

Frequently asked questions

Is my CSS sent to a server?

No. Formatting runs entirely in your browser with JavaScript, so your CSS never leaves your device. The page keeps working offline once it has loaded.

How does the formatter decide where to break lines?

It tokenizes the CSS on the structural characters { } and ;. Each selector or at-rule prelude gets its own line with the opening brace, every declaration sits on its own indented line ending in a semicolon, and the closing brace drops to its own line. A blank line separates top-level rules for readability.

Does it handle nested at-rules like @media?

Yes. Rules inside @media, @supports and similar blocks are indented one extra level for each layer of nesting, so a declaration two blocks deep is indented twice. The prelude such as @media (max-width:600px) is kept on one line with its brace.

Will it change my property values, colors or comments?

No. It only normalizes whitespace and layout. Values, colors, quoted strings, url() contents and block comments are captured verbatim by the tokenizer and never re-spaced, so hex colors, font stacks and calc() expressions come out untouched.

Does it add a semicolon to the last declaration?

Yes. A final declaration written without a trailing semicolon still gets one in the output. This makes the result consistent and safe to extend, since every declaration ends the same way.

Can I run it on already-formatted CSS?

Yes. The formatter is deterministic and idempotent, so reformatting tidy CSS returns the same result without piling on extra blank lines or indentation. That makes it safe to run as a quick cleanup pass anytime.

What indentation can I choose?

Two spaces, four spaces, or a tab, selected with the toggle under the input. Pick whatever matches your project's code style; the choice only affects the leading whitespace, not the structure.

Does it minify CSS as well?

No. This tool only expands and beautifies CSS to make it readable. To shrink CSS for production you would use a minifier, which is the reverse operation of what this tool does.

Does it validate my CSS or catch errors?

No. It reformats whatever you paste and does not check that selectors, properties or values are valid. Malformed input is laid out as best it can, so use a linter or your browser dev tools to catch actual CSS errors.

Learn more

  • Minified vs formatted CSS

    Why CSS gets minified for production and beautified for editing, what each version is for, and how to move safely between them.

Related tools