CSS Formatter

Paste a minified stylesheet or a block of CSS written on one line and get readable rules: each property on its own line, a space after every colon, media queries and nested rules indented, and selector lists split one per line. Strings, url() values and comments come through unchanged. It works as you type and stays in your browser.

Language
Indent

31 lines

Formatting runs in your browser. What you type never leaves this device.

Features

  • One declaration per line with consistent "property: value;" spacing

  • @media, @supports, @layer and nested rules indented level by level

  • Selector lists on separate lines, or kept on one line if you prefer

  • Strings, url() and data: URIs, calc() and comments left exactly as written

  • Indent with 2 spaces, 4 spaces or tabs, and a blank line between rules

  • Copy the result or download it as a .css file

When to format CSS

Editing a theme's minified stylesheet

WordPress and Shopify themes often ship style.min.css. Format it to find the rule that sets a colour or spacing before overriding it.

Debugging styles copied from DevTools

Styles copied from the browser come out on one line. Formatting them makes it easy to see which property is overriding another.

Consistent code before a commit

Normalise indentation and spacing in a hand-written stylesheet so diffs in review show only real changes.

How CSS is formatted

The rules applied

  • An opening brace stays on the selector line; each declaration goes on its own line, ending in a semicolon.
  • Property names are lowercased. Custom properties such as --brand-colour keep their case, because they are case-sensitive.
  • Combinators get single spaces around them, so .nav>li becomes .nav > li.
  • !important is written with one space before it.
  • Comments are kept on their own lines in place.

What it does not do

The formatter does not reorder properties, remove duplicates, add vendor prefixes or check that values are valid. SCSS and Less files with plain nesting format well, but // line comments are not recognised as comments. To shrink CSS for production, use the CSS Minifier instead.

CSS Formatter - FAQ