Every team has one stylesheet nobody wants to open. It might be a minified production file that someone copied back into the project, a snippet pasted from a forum with the indentation of three different authors, or a file that was written in a hurry and never laid out at all. The CSS works, in the sense that pages render. It fails at the other job a stylesheet has: being read, reviewed and safely changed by the next person.

Readability is not decoration. A reviewer scanning a pull request, a teammate hunting the rule that styles a button, a future you trying to edit a file at midnight: all of you depend on structure being visible. This guide shows how to restore that structure with the free CSS Formatter on Ovatly, and how to make the formatting choices that keep a whole team reading the same file the same way.

Contents

  • Quick answer
  • What readable CSS actually looks like
  • What formatting changes, and what it refuses to change
  • How to format CSS for your team, step by step
  • Worked example: one line becomes a stylesheet again
  • Limitations and honest expectations
  • Common mistakes
  • FAQs
  • Conclusion

Quick answer

Paste your CSS into the CSS Formatter, choose an indent size of 2 or 4 spaces, and press Format CSS. The stylesheet comes back with one declaration per line and consistent indentation, ready to copy or download. Formatting changes whitespace and line breaks only: your selectors, your values and the order of your declarations are all preserved exactly. Agree on one indent size for the project, ideally the one your codebase already uses, and format any copied or minified CSS before it is reviewed or edited.

What readable CSS actually looks like

Readable CSS has a shape your eye learns once and then recognises everywhere. One declaration per line, so each property and value pair can be scanned, compared and commented on individually. Consistent indentation, so a rule's contents sit visibly inside its braces and nested blocks line up at predictable depths. A closing brace on its own line, so the end of every rule is a landmark rather than something buried mid-line.

That shape is what makes review possible. In a formatted file, a changed value stands out in a diff because only its line changed. In a one-line file, the same change rewrites the entire line, and the diff tells the reviewer nothing except that something, somewhere, is different. Formatting is what turns a stylesheet from a blob into a document a team can discuss line by line.

It also makes hand-edits safe again. The formatter exists for exactly the files that need editing most: minified production CSS you need to inspect, copied snippets you need to adapt, and sloppily indented files you need to clean up before touching. Editing compressed CSS directly is how declarations get changed in the wrong rule; formatting first is how you avoid it.

What formatting changes, and what it refuses to change

The formatter's scope is deliberately narrow, and the narrowness is the feature. It changes whitespace and line breaks. It does not change your selectors. It does not change your values. The stylesheet that comes out styles your pages in precisely the same way as the stylesheet that went in; only its layout is different.

One refusal deserves emphasis, because teammates often ask for the opposite: the formatter does not sort your properties alphabetically. Declaration order is preserved exactly, and that is not laziness, it is correctness. In CSS, order matters in the cascade: when two declarations compete, the later one can win. A tool that tidied your declarations into alphabetical order would be quietly rewriting your stylesheet's behaviour. A formatter that respects the cascade leaves the order alone and tidies only the spacing.

The same discipline applies to the file as a whole. Nothing is added, nothing is removed, nothing is renamed. That is why formatting is safe to apply to code you did not write and do not yet understand: you are changing how it reads, never what it does.

How to format CSS for your team, step by step

  1. Agree on the indent size first. The CSS Formatter offers 2 or 4 spaces; check what the rest of your project uses and match it, so the stylesheet joins the codebase instead of starting a second style inside it.
  2. Open the formatter and paste your CSS into the input box: the minified file, the copied snippet or the sloppy draft, whichever needs rescuing.
  3. Choose the agreed indent size and press Format CSS.
  4. Copy or download the formatted stylesheet and put it where the team works on it. The minified version is a build output; the formatted version is the source people read and edit.
  5. Make formatting part of the routine: any CSS that arrives compressed or copied from elsewhere gets formatted before it is reviewed, not after someone has already struggled through it.

Worked example: one line becomes a stylesheet again

Take the formatter's own example, the kind of line that production files and copied snippets are made of:

body{margin:0;color:red}

Formatted with a 2-space indent, it comes back as:

body {
  margin: 0;
  color: red
}

Nothing moved except the layout. The selector is still body. The declarations are still margin then color, in that order, with the same values. What changed is everything a teammate experiences: the rule has a visible start and end, each declaration has its own line to be read, reviewed or edited, and a diff against the next version will show exactly which line changed.

Scale that up to a real file of several hundred rules and the effect compounds. A copied snippet dropped into your stylesheet stops being a foreign blob and starts matching the surrounding code, because the formatter applied the same one-declaration-per-line shape and the same indent throughout. Consistency is what lets a reader stop decoding layout and start reading meaning.

Limitations and honest expectations

The formatter works on plain CSS only. SCSS nesting and Less variables are not supported, so preprocessor files need compiling first; format the compiled output instead.

Structure problems in the source limit what formatting can do. A missing closing brace can throw the indentation off, because the formatter is laying out the nesting the file actually contains. Helpfully, the tool tells you when the CSS cannot be formatted, and thrown-off indentation in the output is itself a useful signal that the source has a structural error worth fixing before anyone formats for readability.

Formatting also cannot rescue meaning. It will not rename confusing classes, group related rules, add the comments your team wishes existed or remove CSS that is no longer used. Those are human editing jobs. What formatting does is make those jobs possible to do safely, by giving you a file you can read while you do them.

Common mistakes

  • Mixing indent sizes across files. Half the project at 2 spaces and half at 4 makes every file look slightly foreign. Pick one size, the one the project already leans towards, and use it everywhere.
  • Asking the formatter to sort declarations. It will not, and you should not want it to: order matters in the cascade, so alphabetical tidying can change behaviour.
  • Editing the minified file directly. Compressed CSS is where edits land in the wrong rule. Format it first, edit the readable version, and treat minified output as something you generate, not something you maintain.
  • Formatting as a substitute for review. A tidy file is easier to review, but tidy is not the same as correct. Layout being clean says nothing about whether the values are right.
  • Expecting preprocessor support. SCSS and Less will not format correctly. Compile to plain CSS, then format that.

FAQs

Can it format CSS copied from a minified file? Yes, that is its main use. One-line production CSS comes out as a normally indented stylesheet, with one declaration per line, ready to read and edit.

Does it sort my properties alphabetically? No. Declaration order is preserved exactly, because order matters in the cascade. Sorting declarations could change which rule wins, so the formatter never does it.

Does formatting change my selectors or values? No. Formatting changes whitespace and line breaks only, never your selectors or values. The stylesheet styles pages exactly as it did before; it is simply laid out so people can read it.

What indent sizes can I choose? 2 or 4 spaces. Pick the one your project already uses, so the formatted stylesheet matches the rest of your codebase and the next reader sees one consistent style.

Does it work with SCSS or Less? No. The formatter works on plain CSS. SCSS nesting and Less variables are not supported, so format the compiled CSS output instead.

Conclusion

A stylesheet your teammates can read is a stylesheet they can review, fix and extend without fear. The CSS Formatter does the mechanical part: one declaration per line, one consistent indent, and your selectors, values and declaration order left exactly where you put them. Pair it with the checking habit from our companion guide on how to check a minified CSS file for errors, and both directions of the workflow are covered. The rest of the series lives in the Developer Tools archive.