Why We Built the CSS Formatter
A minified stylesheet crushes every rule onto one line, making it hard to scan for a specific selector in dev tools. This formatter reconstructs the visual structure of your CSS — one rule, one declaration per line — without changing a single value.
How to Use It
Paste your CSS, choose 2 or 4-space indentation, and select "Format CSS". The tool rebuilds each selector block and its declarations onto properly indented lines, giving you a readable stylesheet back instantly, entirely in your browser.
How the Formatter Works
The tool tracks braces, colons, and semicolons to rebuild each selector block and its declarations on separate, properly indented lines, without changing any selector, property, or value.
Safe and Non-Destructive
Reformatting only changes whitespace. The resulting CSS behaves identically to the original, so nothing about how it renders your page changes.
Example: before and after
Before (minified, one line):
.card{padding:8px;margin:0 auto}@media (max-width:600px){.card{padding:4px}}After formatting (2 spaces):
.card {
padding: 8px;
margin: 0 auto;
}
@media (max-width: 600px) {
.card {
padding: 4px;
}
}The rules, values and order are the same; only the spacing and line breaks are new.
Formatter vs minifier: which do you need?
- Formatter (this tool): adds line breaks and indentation, so people can read and edit the CSS. Use it when you’re inspecting a stylesheet, debugging, or learning from someone else’s code.
- Minifier: removes spaces, line breaks and comments to make the file smaller, so pages load faster. Use it on the CSS you publish. Try the CSS Minifier.
A common workflow: keep a formatted version for editing, and serve the minified version on your live site.
Formatting CSS in your code editor
- VS Code: open the .css file and press Shift + Alt + F (Windows), Shift + Option + F (Mac) or Ctrl + Shift + I (Linux) to format the whole document.
- Prettier: run
npx prettier --write styles.cssto format a file from the command line, or set it to format on save. - This tool is handy when you don’t have an editor open, for example for a snippet copied from a browser’s developer tools or a CMS.
Working with other code? Try the HTML Formatter or the JavaScript Formatter.
Common Mistakes to Avoid
Formatting a live production stylesheet directly
Solution:
This tool is for reading and understanding CSS, not for safely editing a live deployed stylesheet. Edit your actual source files, then minify as part of your normal build process.
Assuming formatting validates your CSS
Solution:
This tool reindents based on braces and semicolons — it does not check for invalid properties, typos, or browser support.
Expecting comments to be preserved with exact formatting
Solution:
Comments are stripped before reformatting to keep the indentation logic simple. If you rely on structural comments, keep a separate annotated copy of your source.
Frequently Asked Questions
No — it reindents based on structure (braces, colons, semicolons). It does not check property names or values for correctness.
No. Formatting only changes whitespace — no selector, property, or value is altered, so rendering is unaffected.
Yes — toggle between 2-space and 4-space indentation before formatting.
No. Formatting happens entirely in your browser — nothing is sent to a server.
Formatting adds line breaks and indentation so CSS is easy to read. Minifying removes them to make the file as small as possible. Both keep the same rules and values, so the page looks the same either way.
Open the CSS file and press Shift + Alt + F on Windows, Shift + Option + F on Mac or Ctrl + Shift + I on Linux. VS Code formats the whole file using its built-in CSS formatter.

