200 tools

Web Developer Tools · · 4 min read

How to Beautify and Format CSS

Use the CSS Beautifier to turn minified or cramped CSS into clean, indented rules with 2-space, 4-space, or tab indentation.

To beautify CSS, paste it into the CSS Beautifier, pick an Indent size (2 spaces, 4 spaces, or Tab), and read the formatted result in the output box — it reformats live as you type or paste, with no button to click.

What the CSS Beautifier does

Minified production CSS, stylesheets copied out of a browser's dev tools, or rules typed quickly all tend to end up as dense, hard-to-scan text with everything crammed onto one or two lines. The CSS Beautifier reformats that stylesheet: it puts each property on its own line, indents the contents of every rule and @media block, and adds blank lines between rule blocks so you can see where one selector ends and the next begins — all without changing which properties apply to which elements. It runs on js-beautify, the same formatting engine used by many code editors, loaded directly in your browser.

How to beautify CSS with Toolbench

  1. Open the CSS Beautifier.
  2. Paste your CSS into the input box on the left.
  3. Choose an Indent size from the dropdown: 2 spaces (the default), 4 spaces, or Tab.
  4. Read the formatted CSS in the output box on the right — it reformats instantly, with no "Beautify" button to press.
  5. Click Copy to copy the result, or use the Send to → menu to pass the output straight into another tool, such as the CSS Minifier.

Indentation width is the only setting — the engine preserves your selectors, property values, and comments exactly as written.

A real worked example

Starting from this cramped, single-line CSS:

.card{display:flex;flex-direction:column;padding:16px;border:1px solid #ddd}.card h1{font-size:1.5rem;margin:0 0 8px}.card p{color:#333;line-height:1.5}@media (max-width:600px){.card{padding:8px}}

With the default 2 spaces indent, the CSS Beautifier produces:

.card {
  display: flex;
  flex-direction: column;
  padding: 16px;
  border: 1px solid #ddd
}

.card h1 {
  font-size: 1.5rem;
  margin: 0 0 8px
}

.card p {
  color: #333;
  line-height: 1.5
}

@media (max-width:600px) {
  .card {
    padding: 8px
  }
}

Each rule gets its own block with a blank line before the next one, every declaration moves to its own indented line, and the nested rule inside @media picks up a second indent level. Notice the last declaration in each rule (border: 1px solid #ddd, for example) keeps no trailing semicolon, because the original input didn't have one there — the beautifier doesn't add semicolons you didn't write.

How the indent options compare

Indent setting What changes When to use it
2 spaces (default) Each nesting level adds two spaces Matches most CSS style guides and keeps media-query blocks from getting too wide
4 spaces Each nesting level adds four spaces Easier to scan visually; common in some editor defaults
Tab Each nesting level adds one tab character Lets each developer's editor render the indent width they prefer

All three options leave selectors, property values, units, colors, and comments untouched — only indentation, line breaks, and the spacing around colons and braces change.

Tips and common mistakes

  • It won't fix invalid CSS. The beautifier reformats structure; it doesn't catch typos in property names or close unmatched braces for you. If the output still looks off, check the original CSS for a missing }.
  • It adds blank lines between rule blocks automatically. Even if your input has every rule crammed together with no blank lines, the beautifier inserts one between each top-level rule and @media block to keep them visually separated.
  • Going the other way? If you need compact CSS for production, run the beautified output through the CSS Minifier — the two tools are inverses of each other.
  • Formatting a <style> block from an HTML page? Pull just the CSS out first. The CSS Beautifier expects standalone stylesheet content, not a full HTML document.

Frequently asked questions

How do I format messy or minified CSS?

Paste it into the CSS Beautifier. It reformats the stylesheet instantly, putting each declaration on its own indented line — no button to click, and no account needed.

What's the default indent size?

Two spaces per nesting level. Switch to four spaces or a tab character using the Indent dropdown above the input box.

Does beautifying change how my styles work?

No. Beautifying only changes whitespace and line breaks in the source — selectors, property names, values, and comments are untouched, so the stylesheet applies identically before and after.

Will it add missing semicolons or fix broken syntax?

No. The beautifier only reformats spacing and indentation; it doesn't add semicolons you left out or repair invalid CSS.

Is my CSS sent to a server?

No. Formatting runs in your browser using the js-beautify library. If you're signed in, your input syncs privately to your account; if you're signed out, nothing is saved anywhere.

More guides

All guides →