Format
Rewrites your CSS with one rule per line, one declaration per line, and consistent indentation. Turns minified or messy styles into clean, readable code.
.a{color:red;margin:0}After.a {
color: red;
margin: 0;
}Paste minified or messy CSS and get it back with one declaration per line and everything indented. Or go the other way and minify your styles to make the file smaller. Everything runs in your browser, so your code stays on your device.
CSS is often shipped minified, with all the whitespace removed so it loads faster, which makes it very hard for a person to read. A formatter, also called a beautifier, does the reverse: it rewrites the styles with one declaration per line and consistent indentation, so the structure is clear. This tool formats your CSS for reading and can minify it again when you are ready to ship. It changes only the spacing, never how your styles apply.
Rewrites your CSS with one rule per line, one declaration per line, and consistent indentation. Turns minified or messy styles into clean, readable code.
.a{color:red;margin:0}After.a {
color: red;
margin: 0;
}Removes comments and the extra spaces and line breaks to make the file smaller. Good for shipping CSS to production so pages download a little faster.
.a {
color: red;
}After.a{color:red}Choose 2 or 4 spaces for each level of nesting, so the formatted CSS matches the style used in the rest of your project.
2 spaces or 4 spacesAfterYour choice per levelA formatter helps whenever a stylesheet is hard to read or needs to be smaller. These are the cases that come up most:
Once your CSS is formatted, these standard references explain how each part actually works:
This tool formats CSS with Prettier, which most front end projects already use. To apply the same formatting to your stylesheets:
| To | Use |
|---|---|
| Format every CSS file | npx prettier --write "**/*.css" |
| Check without changing files | npx prettier --check "**/*.css" |
| Keep settings in the repo | Add a .prettierrc file with your "tabWidth" |
Prettier sorts nothing and changes no values, so the order of your rules and properties stays exactly as you wrote it.
Working across stylesheets and markup? These formatters run the same way, right in your browser: