CSS Formatter

Tidy stylesheets into a consistent, readable shape.

Code Formatters Free, no sign-up Runs in your browser

CSS Formatter tool

About the CSS Formatter

CSS Formatter expands a stylesheet into a consistent shape: one selector per line, one declaration per line, a space after each colon, and a semicolon on every declaration including the last. Minified CSS becomes readable again, and inconsistently written CSS becomes uniform.

Nested structures are handled properly. Media queries, supports blocks, keyframes and layers all indent their contents one level further, which is what makes a long responsive stylesheet navigable. Comments are preserved in place rather than being stripped, because a comment that moves is worse than no comment.

The formatter changes whitespace and nothing else. Property order, selector specificity and values are left exactly as written, so the formatted file behaves identically to the original and a diff shows only what you expect.

How to use the CSS Formatter

  1. Paste your CSSMinified or hand-written.
  2. Choose an indent sizeTwo spaces, four spaces or a tab.
  3. Press FormatThe expanded stylesheet appears below.
  4. Copy or downloadTake the formatted CSS.

Features

  • One selector and one declaration per line
  • Indents media queries, supports, keyframes and layers
  • Preserves comments in place
  • Adds the final semicolon consistently
  • Normalises spacing around colons, commas and braces
  • Leaves property order and values untouched
  • Reports unbalanced braces
  • Copy or download the result

Who uses this tool

The css formatter is used by writers, developers, students, marketers and anyone else who needs the job done once without installing software. Common cases include:

  • Reading a minified stylesheet
  • Normalising CSS written by several people
  • Making a stylesheet diff readable
  • Finding an unbalanced brace
  • Preparing CSS for a code review

Frequently asked questions

Does formatting change how my styles apply?

No. Only whitespace changes. Selector order, specificity and values are untouched, so the formatted stylesheet behaves exactly like the original.

Are comments kept?

Yes, in place. Comments often explain why a rule exists, and a formatter that discards or relocates them destroys information that cannot be recovered.

How are media queries handled?

The query stays on its own line and the rules inside it are indented one level further, which is what makes the structure of a responsive stylesheet readable at a glance.

What about unbalanced braces?

The tool reports them rather than guessing. An unbalanced brace in CSS silently swallows every rule after it, so finding it is usually the whole reason you came.

Does it reorder or merge properties?

No. Merging duplicate properties or shorthanding values changes meaning in ways that depend on context, so the formatter leaves those decisions to you.

Is my stylesheet uploaded?

No. Everything runs in your browser.

If the css formatter is not quite what you need, these other free tools solve closely related problems.

CSS Minifier

Minify CSS by removing comments, whitespace and redundant characters.

Code Formatters Use tool

HTML Formatter

Pretty-print HTML with consistent indentation, or collapse it back down.

Code Formatters Use tool

JavaScript Formatter

Format JavaScript with consistent indentation, spacing and statement breaks.

Code Formatters Use tool

Live HTML Editor

A three-pane editor with a live preview that updates as you type.

Developer Tools Use tool

CSS Gradient Generator

Design linear and radial gradients with live preview and copyable CSS.

Color Tools Use tool