How to use the CSS Formatter
- 1
Paste the stylesheet
Paste minified or messy code, or open a .css, .scss or .less file.
- 2
Choose the language
Pick CSS, SCSS or Less so the matching parser is used. The download extension follows your choice.
- 3
Set indent and quotes
Choose 2 or 4 spaces or tabs, and tick “Prefer single quotes” if your codebase uses them.
- 4
Copy the result
Copy or download the formatted file and keep editing it in your editor.
Features
One declaration per line
Each property sits on its own line inside indented rules.
Lower-case hex
#1E40AF becomes #1e40af; keywords and URLs are not lower-cased.
Number tidying
Leading zeros are added (.3s → 0.3s) and unit case is normalised (0PX → 0px).
Selector lists split
Comma-separated selectors each get their own line.
Nesting aware
SCSS and Less nesting, variables and mixin calls are indented correctly.
Runs locally
Prettier runs in your browser; nothing is uploaded.
Who uses it — and for what
Debugging a live site
Expand a minified stylesheet from a production site to find the rule causing a layout bug.
Theme customisers
Make a WordPress or Shopify theme’s CSS readable before overriding it.
Code reviewers
Normalise style before comparing two versions in a diff tool.
Learners
Study how other sites build layouts by reading their formatted CSS.
What the formatter does
It puts every declaration on its own line, indents nested rules (including SCSS nesting and media queries), adds a space after colons and commas, lowercases hex colours consistently, keeps the blank lines you already had between rules (it does not add new ones) and normalises quotes. This turns a minified stylesheet from a CDN or a theme into something you can read, debug and edit. Use the CSS Minifier to shrink it again for production.
Formatting uses Prettier, the most popular code formatter, loaded into your browser — the same output you would get from the Prettier extension in VS Code with these settings.
Tips
- Pick SCSS or Less when your code uses variables, mixins or nesting, so it is parsed with that language’s rules.
- Formatting never changes which styles apply; it only changes whitespace and quote style.
- Errors show the line and column of the first problem, often a missing brace or semicolon.
Everything runs in your browser — your code and data are never uploaded, so it is safe to paste private config files and API responses.
Formatter vs minifier: opposite jobs
A formatter adds whitespace for humans; a minifier removes it for machines. They also disagree on values: the formatter writes 0.3s with a leading zero for readability, while the CSS Minifier writes .3s to save a byte. Neither changes which styles apply.
| CSS Formatter | CSS Minifier | |
|---|---|---|
| Output | Indented, one declaration per line | A single line |
| Comments | Kept | Removed except /*! licences |
| Values | Case and leading zeros tidied, otherwise unchanged | Shortened (red, #fff, 0) |
| Rules | Never moved or merged | May be merged when restructuring is on |
| Languages | CSS, SCSS, Less | Plain CSS |
A typical workflow: format a minified file to understand it, edit the readable version, then minify again for production.
Choosing the right language mode
The three modes use Prettier’s PostCSS-based parsers. In practice the CSS parser is forgiving — SCSS-style nesting and $variables pasted in CSS mode may still format — but choosing the matching mode is the reliable route, because each language has syntax the others treat differently:
- SCSS —
//line comments,@mixin/@include, maps such as(sm: 640px, md: 768px), placeholder selectors like%button-base. - Less —
@variables, mixin calls like.rounded(4px);, guards and operations. - CSS — modern native nesting, custom properties,
@layer,@containerand other current at-rules.
If you see an error such as CssSyntaxError: Unclosed block (1:1), the parser reached the end of the file while a { was still open; the line and column point at the rule that was never closed. To check how the formatted selectors compete with each other, use the CSS Specificity Calculator.
Worked examples
Un-minifying a stylesheet
Input:
.nav a,.nav button{color:#1E40AF;padding:8px 12px}.nav a:hover{text-decoration:underline}@media (max-width:640px){.nav{flex-direction:column}}Formatted as CSS, 2 spaces:
.nav a,
.nav button {
color: #1e40af;
padding: 8px 12px;
}
.nav a:hover {
text-decoration: underline;
}
@media (max-width: 640px) {
.nav {
flex-direction: column;
}
}No blank lines are inserted between rules: Prettier preserves blank lines that were in your source but does not add new ones.
SCSS with single quotes and 4 spaces
$brand:#e11d48;.card{border:1px solid $brand;&:hover{box-shadow:0 2px 8px rgba(0,0,0,.2)}.title{font-family:"Inter",sans-serif}}becomes
$brand: #e11d48;
.card {
border: 1px solid $brand;
&:hover {
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.title {
font-family: 'Inter', sans-serif;
}
}Value normalisation
a{color:#FFF;background:URL(img.png);margin:0.5em 0PX;transition:all .3S}becomes
a {
color: #fff;
background: URL(img.png);
margin: 0.5em 0px;
transition: all 0.3s;
}Hex colours and units are lower-cased and a leading zero is added, but the URL() function name is left alone. The formatter does not shorten values either — 0px stays 0px — because changing values is a minifier’s job.
Pro tips
- Format before you diff two versions of a stylesheet; otherwise whitespace differences hide the real change.
- Untick “Prefer single quotes” to get Prettier’s default double quotes in font names, URLs and content strings.
- Use the same indent as your editor’s Prettier config so files you format here are not reformatted again on save.
Glossary
- Beautify
- Another word for formatting: adding line breaks and indentation to make code readable.
- Declaration
- One property and value pair inside a rule, such as color: red.
- PostCSS
- A widely used tool for parsing and transforming CSS; Prettier uses parsers from its ecosystem.
Frequently asked questions
Can it un-minify CSS?
Yes — paste minified CSS and it comes back fully expanded and indented.
Does it support SCSS and Less?
Yes, choose the language in the options.
Will it reorder my properties?
No, the order of rules and declarations is kept.
Does it remove comments?
No. Comments are kept in place; only whitespace, quote style and the case of hex colours and units change.
Can it convert SCSS to CSS?
No. It formats each language as it is. Compiling SCSS or Less to CSS needs a Sass or Less compiler.
Does it fix invalid CSS values?
No. A misspelled property or value is formatted like any other; the formatter checks structure, not meaning.
Last updated 2026-11-28 · Built by Vinayak Agarwal · Part of Developer & Web (77 tools)