CSS formatter

Paste compressed or untidy CSS and get a readable stylesheet back, with one selector and one declaration per line and consistent indentation. Pick the indentation and whether rules are separated by a blank line.

  • Free
  • No sign-up
  • Runs in your browser

Runs in your browser — your text is never sent to our servers.

How to use CSS Formatter

  1. Paste your CSS into the Input box, or click Open a file to load a .css file.
  2. Choose the Indentation (2 spaces, 4 spaces or Tab) and tick or untick Blank line between rules.
  3. Read the formatted CSS in the Output box. The line count appears under it.
  4. Click Copy, or click Download to save formatted.css.

Features

  • Puts each declaration on its own line
  • Puts each selector of a comma list on its own line
  • Indentation of 2 spaces, 4 spaces or a tab
  • Optional blank line between rules
  • Indents the rules inside @media blocks
  • Runs in your browser, so the stylesheet is not uploaded

Supported formats and limits

  • Maximum input: 5,000,000 characters

Examples

InputResult
.card{margin:0 auto;padding:1rem}.card h2,.card h3{font-size:1.25rem;color:#333}@media (min-width:600px){.card{padding:2rem}}.card { margin: 0 auto; padding: 1rem } .card h2, .card h3 { font-size: 1.25rem; color: #333 } @media (min-width:600px) { .card { padding: 2rem } } — Default settings (2 spaces, blank line between rules).

Limitations

  • The tool only changes layout. It does not validate the CSS or check that property names and values exist.
  • Existing characters are kept as written, including a missing semicolon after the last declaration and spacing inside values or media queries.
  • It does not minify. To make a stylesheet smaller, use the CSS minifier.
  • Input is limited to 5 million characters.

Learn more

CSS is a list of rules. Each rule has a selector, such as .card h2, and a block of declarations in braces, each pairing a property with a value. The language ignores almost all whitespace between those parts, so the same stylesheet can be written in thousands of lines or squeezed into one.

Build tools often produce the one-line version to save bytes. It downloads faster but it is painful to read, which is when a formatter helps: one declaration per line makes it easy to see what a rule does, to spot a duplicated property and to compare two versions in a diff.

A formatter only moves whitespace. It does not know whether a property is spelled correctly, whether a value is valid or whether two rules conflict, so a typo stays a typo. For a real check, read the browser's developer tools, which mark unknown or overridden declarations. The MDN CSS documentation is the reference for syntax and properties.

Frequently asked questions

Does formatting change how my page looks?

No. Only spaces, tabs and line breaks between CSS tokens change, and browsers ignore them. Whitespace inside strings and url() values is left as it is.

Can it fix a CSS error?

No. It re-indents the text you give it and does not check that the CSS is valid. Use your browser developer tools or a CSS validator to find errors.

How do I turn formatted CSS back into a compact file?

Use the CSS minifier, which removes whitespace and comments to reduce the file size.

Is my stylesheet uploaded?

No. The formatting runs in your browser and nothing is sent to a server.

Sources

Last reviewed: September 30, 2026