Skip to content
Tooletto

CSS Formatter

Format CSS, SCSS and Less with consistent indentation, or minify it to the smallest valid output. Parsed properly, so nested rules, media queries and custom properties survive intact.

  • Files never leave your device
  • Free, no signup
  • No watermarks
  • Works offline once loaded
Loading tool…

How to css formatter

  1. 1

    Paste your CSS

    Plain CSS, SCSS or Less all parse correctly.

  2. 2

    Format or minify

    Beautify for readability, or compress for production.

  3. 3

    Copy or download

    The result is ready to paste straight back into your project.

Why CSS needs an actual parser rather than a regex pass

CSS looks simple enough to reformat with a handful of find-and-replace rules — add a newline after every semicolon, indent inside braces — until nesting, media queries, and modern features like custom properties and container queries are actually in the file. A regex-based approach has no real concept of nesting depth, so it cannot correctly indent a media query containing several nested selectors, and it has no way to distinguish a semicolon that ends a declaration from one that appears inside a string value or a custom property containing arbitrary text. Parsing the stylesheet into an actual structure first — understanding which rule is nested inside which, where each block starts and ends — is what makes formatting correct on real, non-trivial CSS rather than only on toy examples.

What minification changes and, deliberately, what it does not

This tool's minification is limited to removing whitespace and comments — the parts of a stylesheet that exist purely for a human reading it and carry no meaning to the browser's rendering engine. It deliberately does not merge duplicate selectors, reorder declarations, or shorten color values like rewriting `#ffffff` to `#fff`, even though a more aggressive minifier could do all three and produce a smaller file. Those transformations can change behaviour in ways that are easy to overlook: merging two rules with the same selector but written at different points in the cascade can change which declaration wins when they conflict, and reordering declarations risks the same. Whitespace removal alone carries no such risk — it cannot change what a browser renders, only how many bytes the file takes to describe it.

Why minification saves less than people expect after gzip

Web servers almost universally compress text assets with gzip or brotli before sending them over the network, and both compression algorithms are very good at exploiting exactly the kind of redundancy that whitespace and consistent indentation represent — repeated sequences of spaces compress extremely well already. This means the gap between a formatted stylesheet and a minified one, once both pass through gzip, is considerably smaller than the uncompressed size difference suggests. Minifying still helps, particularly by removing comments outright rather than merely compressing them, but it is worth knowing that most of the network-transfer benefit modern tooling promises is coming from compression, with minification contributing a smaller additional layer on top.

SCSS and Less formatting versus compiling

Formatting a Sass or Less file means applying consistent indentation and spacing to the source exactly as written — nesting, variables, mixins and control directives all stay intact, in their original preprocessor syntax. That is a different operation entirely from compiling, which resolves variables to their actual values, flattens nested selectors into standalone plain-CSS rules, and executes any mixins to produce their expanded output. Someone expecting compiled CSS out of a SCSS input will be surprised to see the same nested, variable-laden source formatted rather than resolved — this tool is a formatter for the preprocessor language, not a compiler for it.

Frequently asked questions

How much does minifying actually save?

Typically 20–30% before gzip on hand-written CSS, and much less on output that a build tool already processed. Over the network the gzip or brotli layer does most of the work anyway — minification mostly helps by removing comments and redundant whitespace before that.

Does minifying change how my styles behave?

No. Only whitespace and comments are removed; selectors, properties and values are untouched. This tool does not merge rules, reorder declarations or shorten colours, because those transformations can change behaviour in ways that are hard to spot.

Does it support SCSS and Less?

Yes, both are parsed with their own grammars, so nesting, variables and mixins survive formatting. Note it formats them — it does not compile them to CSS.

Why is my CSS rejected?

Usually an unclosed brace or a stray character. The error message includes the line number so you can find it. Templating syntax mixed into the stylesheet will also fail, since it is not valid CSS.

Common css formatter tasks