CSS Formatter

Paste minified or untidy CSS. It comes back with one declaration a line, nested blocks indented and a blank line between rules.

How it works

The formatter reads the CSS once from start to end. Each { opens a block and indents what follows, each ; ends a declaration, and each } closes the block. Rules inside @media, @supports and native CSS nesting are indented one level deeper.

Only whitespace changes. Strings, url() values, comments and selectors keep every character, and values are not rewritten. A space is added after the colon of each declaration, and a selector list is split one selector per line.

It runs on this page and takes up to 2 MB of CSS at a time, which formats in well under a second. Nothing is uploaded.

How to use it

  1. 1 Paste your CSS into the box.
  2. 2 Choose an indent: 2 spaces, 4 spaces or a tab.
  3. 3 Read the formatted CSS below. If a brace is missing, the message names its line.
  4. 4 Press Copy result, or Download to save a .css file.

Good to know

  • Formatting a minified file from a site makes it readable, but comments removed by the minifier do not come back.
  • A colon inside a selector, such as a:hover, is left alone. Only the colon of a declaration gets a space after it.
  • To shrink the result again for production, run it through the CSS Minifier.
  • If the output looks wrong, check for a missing } in the input. The error message gives the line of the brace that is never closed.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

Reading a minified stylesheet you need to debug

Minified CSS is built for browsers, not people. Say a button on a live site looks wrong and the only CSS you have is one line from the production bundle: .btn{padding:.5rem 1rem;border-radius:4px}.btn:hover,.btn:focus-visible{background:#2f68c5}@media (max-width:600px){.btn{width:100%}}. Every rule is there, but finding the one that sets the width on a phone means reading the line character by character.

Paste it here and the structure appears. The first rule becomes .btn { with padding: .5rem 1rem; and border-radius: 4px; on their own lines, indented by two spaces. The hover rule shows its two selectors one per line, .btn:hover, and .btn:focus-visible, so it is clear that keyboard focus gets the same darker background as the mouse. The media query becomes a block of its own with the .btn rule indented inside it, and width: 100%; one level deeper again.

Nothing in the values changes. The .5rem stays .5rem rather than becoming 0.5rem, and #2f68c5 is not shortened or renamed. That matters when you copy a rule back into source code or compare it with a file in your repository: the formatted text is the same CSS, so a diff shows only the lines you meant to change. When you are done editing, the CSS Minifier takes it back down to one line.

The formatter also catches a common accident. If a stylesheet is missing a closing brace, everything after it ends up inside the rule above, and browsers then ignore large parts of the file without saying why. Here the formatter refuses to guess and names the line of the { that is never closed, so you can fix the input rather than ship the mistake.

There are limits. The formatter does not validate properties or values, so a typo such as colr: red is formatted like any other declaration. It does not restore comments that a minifier already removed. It does not sort properties, merge duplicate rules or convert between colour formats. Preprocessor syntax such as Sass mixins and loops may not format cleanly, because the formatter reads plain CSS. And it caps input at 2 MB to keep the page responsive.

Frequently asked questions

Will formatting change how my CSS works?

No. Only whitespace is added or removed between tokens. Selectors, values, strings and comments stay exactly as they were, so the browser reads the same rules.

Does it support media queries and CSS nesting?

Yes. Any block inside another block is indented one more level, whether it is a rule inside @media, @supports or @layer, or a nested rule such as &:hover inside a parent rule.

Does it sort properties or fix errors?

No. It does not reorder properties, merge rules or fix invalid values. It reports unbalanced braces, because those make the structure impossible to indent, and leaves everything else to you.

Is there a size limit?

Up to 2 MB of CSS at a time. That is larger than almost any real stylesheet. For more, split the file and format the parts.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.