CSS has no opinion about how you lay it out. A browser reads a rule the same way whether its declarations sit on twelve lines or one, which is why the same stylesheet turns up in wildly different shapes: the airy, indented file a developer writes by hand, the dense block a framework ships, and the single line a production server delivers. Those shapes have names, expanded, compact and one-line, and knowing which is which makes it easier to pick the right one for the job, and to know what a formatting tool will and will not do.

This guide walks through the three styles using the same rule in each, covers where each style earns its place, and is plain about the role of the free CSS Formatter on Ovatly: it produces one of the three styles, the expanded one, and understanding that up front saves a wasted trip.

Contents

  • Quick answer
  • The three styles, side by side
  • Expanded style: the reading and writing form
  • Compact style: the middle ground
  • One-line style: the shipping form
  • How to format CSS into expanded style, step by step
  • Worked example: one rule, three styles
  • Limitations and alternatives
  • Common mistakes
  • FAQs
  • Conclusion

Quick answer

Expanded style puts one declaration per line inside an indented block. Compact style groups a rule onto fewer lines, often the selector and declarations sharing a line or two. One-line style crushes each rule, or a whole file, onto a single line with almost no whitespace. All three are the same CSS: they differ only in whitespace and line breaks, never in selectors, values or declaration order. Write and review in expanded style, which is what the CSS Formatter produces when you press Format CSS, with your choice of a 2 or 4 space indent. Ship one-line style, which comes from minifying, not formatting.

The three styles, side by side

The fastest way to see the difference is to watch one rule change shape. In expanded style it looks like this:

.nav {
  margin: 0;
  padding: 0;
  list-style: none;
}

In compact style, the same rule tightens up:

.nav { margin: 0; padding: 0; list-style: none; }

And in one-line style, as a minifier would leave it:

.nav{margin:0;padding:0;list-style:none}

Three layouts, one rule. Every selector, declaration and value is identical, and the order is identical too, which matters, because order matters in the cascade. Only the whitespace moved. That is the whole distinction, and it is why converting between styles is a mechanical job a tool can do safely: there is nothing to interpret, only layout to rewrite.

Expanded style: the reading and writing form

Expanded style gives every declaration its own line and indents the block consistently, so a rule reads top to bottom like a list. It is the style of hand-written stylesheets, tutorials and code reviews, and it earns that place on readability. You can scan a rule and count its declarations, spot a duplicate property, or read the cascade in the order it applies. Diffs stay clean too, because changing one value touches one line.

Its cost is size. Line breaks and indentation add characters, and a large expanded stylesheet is noticeably bigger than its minified twin. That cost is paid by developers, not visitors, as long as the file is minified before it ships, which is why the usual workflow is expanded in the source and one-line in production.

Compact style: the middle ground

Compact style keeps a rule together on one or a few lines while leaving spaces that keep it legible. Short rules and utility classes often live happily in this shape, and some developers write small stylesheets this way by choice: a one-declaration rule arguably wastes three lines in expanded form.

The trade is consistency. Compact style has no single agreed shape: one file puts the whole rule on one line, another breaks after the opening brace, a third groups declarations in pairs. Mixed across a codebase, that variety makes scanning harder. Compact also diffs poorly, since several declarations share a line and a small change rewrites the whole line. It is a reasonable personal shorthand and a poor team standard.

One-line style: the shipping form

One-line style removes nearly all whitespace, so rules run together with no line breaks to speak of. It exists for one reason: size. A stylesheet in this form downloads faster, and browsers parse it without caring that no human could follow it.

That is also its limit. One-line CSS is a delivery format, not a working format. Searching it is painful, editing it is risky, and a missing closing brace can throw everything after it off without any visible clue. When you need to inspect or change production CSS, convert it back to expanded style, work there, and let minification crush it again for release.

How to format CSS into expanded style, step by step

  1. Open the CSS Formatter and paste your CSS into the input box, whether it is compact, one-line or just sloppily indented.
  2. Choose an indent size of 2 or 4 spaces.
  3. Press Format CSS.
  4. Copy or download the formatted stylesheet.

The output is expanded style throughout: compressed or messy input comes back as readable rules, one declaration per line.

Worked example: one rule, three styles

The entry example for the formatter is a single minified rule:

body{margin:0;color:red}

That is one-line style at its smallest. Press Format CSS and the same rule returns in expanded style:

body {
  margin: 0;
  color: red
}

A compact rendering of the same rule, written by hand for comparison, would sit between the two:

body { margin: 0; color: red; }

Note what the formatter did and did not do across that conversion. It added line breaks, indentation and spaces around the punctuation. It did not rename anything, shorten red to a hex value, or reorder the declarations. margin still comes before color, exactly as written, because declaration order is preserved exactly. The conversion is purely typographic, which is why it is safe to run on CSS you did not write.

One more honesty point belongs here. The formatter produces the expanded version of that trio, full stop. It has an indent choice, 2 or 4 spaces, but it is not a style switcher with expanded, compact and one-line modes. Paste compact CSS in and you still get expanded output, because expanded is the one job it does.

Limitations and alternatives

The formatter works on plain CSS only. SCSS nesting and Less variables are not supported, so preprocessor source needs compiling to CSS before it can be formatted here.

It also stops at layout. Formatting changes whitespace and line breaks only, never your selectors or values, and it does not sort properties, validate declarations, or remove unused rules. A missing closing brace can throw the indentation off, and the tool tells you when CSS cannot be formatted; both are signals about the source, not formatting options.

For the other styles, use the tool that owns them. One-line output comes from the CSS Minifier, which removes structure for production files. Compact style has no dedicated tool here: it is a hand-writing convention, and the practical route is to keep source in expanded style and let the build decide what ships.

Common mistakes

  • Expecting a style switcher. The formatter produces expanded style only. Asking it for compact or one-line output misunderstands the tool; minifying is the one-line route.
  • Writing production files by hand. One-line style is a build output. Author in expanded style and minify at release.
  • Assuming the styles behave differently. Layout never changes rendering. If a page looks different after formatting, the cause is a real difference in the CSS, such as a brace problem the new indentation made visible.
  • Reordering declarations while reformatting by hand. Order matters in the cascade. Sorting properties can change which declaration wins.
  • Mixing styles across one project. A codebase that drifts between expanded and compact is harder to scan than either used consistently.

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.

Does it sort my properties alphabetically? No. Declaration order is preserved exactly, because order matters in the cascade.

What is the difference between this and the CSS Minifier? This tool adds structure and indentation for humans. The minifier removes them for production files.

Does the formatter offer compact and one-line styles too? No. It produces the expanded readable style, with an indent choice of 2 or 4 spaces. One-line output comes from minifying, which is a separate tool.

Which style should a team write CSS in? Expanded, in almost every case. It is the easiest style to read, review and diff, and the file can always be minified automatically when it ships.

Conclusion

Expanded, compact and one-line are three layouts for the same CSS, and each has its place: expanded for writing and reviewing, compact as a personal shorthand, one-line for delivery. When a stylesheet reaches you in the wrong shape, paste it into the CSS Formatter and it comes back expanded, one declaration per line, ready to read and edit safely. For the practical side of rescuing a production file, the companion guide on how to untangle a one-line CSS file works through the process, and the rest of this series lives in the Developer Tools guides archive.