CSS Formatter
Format and beautify CSS, SCSS and Less online with Prettier. Turn minified or messy stylesheets into readable, consistently indented code in your browser.
Runs in your browser · Nothing uploadedFree · No sign-up
Something not working, or missing a feature? Send feedback
About the CSS Formatter
The CSS Formatter makes compressed or inconsistent stylesheets readable again, one declaration per line with consistent indentation. It understands CSS, SCSS and Less.
Everything runs in your browser, so your input is never uploaded to a server.
How to use the CSS Formatter
- Paste your stylesheet or open a file.
- Choose the syntax (CSS, SCSS or Less) and indentation.
- Copy or download the formatted code.
Example
Input
.btn{display:inline-flex;padding:8px 16px;border-radius:6px}.btn:hover,.btn:focus-visible{background:#2563eb;color:#fff}@media (max-width:600px){.btn{width:100%}}Result
.btn {
display: inline-flex;
padding: 8px 16px;
border-radius: 6px;
}
.btn:hover,
.btn:focus-visible {
background: #2563eb;
color: #fff;
}
@media (max-width: 600px) {
.btn {
width: 100%;
}
}
Each rule and declaration gets its own line, selectors in a list are split one per line, and the @media block is indented. No rule is removed or reordered.
Common mistakes
- Choosing CSS for SCSS code. Nested rules, $variables and @mixin are not plain CSS. If the formatter reports an error on a nested selector, switch the syntax to SCSS or Less.
- A missing closing brace. One unclosed { makes everything after it part of the same rule. The error points to the end of the file; look for the last rule that opened without closing.
- Expecting smaller output. Formatting makes CSS longer and easier to read. For production files use the CSS Minifier, which removes the whitespace again.
Works well with the CSS Formatter
- CSS Minifier: compress the stylesheet again before deploying it.
- CSS Gradient Generator: design a gradient background and paste the CSS in.
- Color Converter: convert HEX colours in the stylesheet to RGB or HSL.
- Text & Code Diff: compare two versions of a stylesheet line by line.
Frequently asked questions
Can I format SCSS with nesting and variables?
Yes. Choose SCSS (or Less) and nested rules, variables and mixins are formatted correctly.
Does it remove unused rules?
No. Formatting never removes or reorders rules; it only changes whitespace and layout.
Does it change colours or units?
Values are kept as written, except that letter case and spacing are normalised. #FFF is printed as #fff, but it is never converted to another format.
Is my stylesheet uploaded?
No. Prettier runs in your browser, so the CSS never leaves your device.
Guides and tutorials
Related tools
JSON Formatter
Format and beautify JSON with configurable indentation and optional key sorting. Errors are reported with exact line and column.
HTML Formatter
Format and beautify messy or minified HTML into clean, indented markup with Prettier, including embedded CSS and JavaScript. Runs locally in your browser.
JavaScript Formatter
Format and beautify JavaScript and JSX online with Prettier. Choose indentation, quotes, semicolons and line width; your code is formatted in your browser.
TypeScript Formatter
Format and beautify TypeScript and TSX online with Prettier, including types, generics and decorators. Choose indentation, quotes and semicolons.
PHP Formatter
Format PHP code online with Prettier for PHP (@prettier/plugin-php): PSR-12 braces, spacing and 4-space indentation. No install, and nothing is uploaded.
SQL Formatter
Format and beautify SQL queries online for MySQL, PostgreSQL, SQLite, SQL Server and more, with keyword casing and indentation options. Runs in your browser.