What is a CSS formatter?
A CSS formatter makes stylesheets readable by putting each rule and declaration on its own line with consistent indentation, or does the reverse and minifies CSS into the smallest equivalent text for production. Developers use it to inspect a site's compressed stylesheet, tidy hand-written CSS, or shrink a stylesheet without a build step.
This formatter beautifies with js-beautify and minifies with a conservative minifier that protects strings, calc() and selector spacing, then shows the size before and after. Your stylesheet never leaves the browser, so unreleased designs stay private.
How to use the CSS Beautifier
1.Paste CSS
A whole stylesheet or a few rules.
2.Beautify or minify
Pick an indentation style for beautifying.
3.Take the result
Copy it or download a .css file; minify shows how much smaller it got.
Example: a compressed card component
The 155-byte sample, three rules on one line:
- Beautified
- 16 lines, 198 bytes
- Minified again
- 155 bytes
- Media query
- nested rule indented one level
Beautifying and then minifying returns exactly the original 155 bytes, a sign nothing was lost.
Safe minification
Minify removes comments, collapses whitespace, drops spaces around braces, colons, semicolons and commas, and removes the last semicolon in each rule. Text inside quotes is never touched, the spaces calc() needs around + and − are kept, and a space before a colon in a selector such as a :hover is preserved, because removing it would change its meaning.
It doesn't rewrite values or merge rules, so the result behaves exactly like the original. Build tools such as Lightning CSS or cssnano can squeeze out more.
Frequently asked questions
Is minified CSS faster?
Slightly: fewer bytes to download and parse. Server compression gives a bigger gain.
Will it break calc()?
No. Spaces around + and − are kept because calc() requires them.
Can I un-minify CSS?
Yes. Paste minified CSS and choose Beautify to get one declaration per line.
Does it handle @media and other at-rules?
Yes; nested blocks are indented when beautifying.
Related tools
HTML Beautifier & Minifier
Indent messy HTML or minify it for production.
JavaScript Beautifier & Minifier
Format JavaScript, or minify it with Terser.
JSON Formatter & Validator
Pretty-print, minify, sort and validate JSON with line-numbered errors.
JSON ↔ CSV Converter
Convert JSON arrays to CSV and CSV back to JSON.
JSON to TypeScript Interface Generator
Generate TypeScript interfaces or types from a JSON sample.
JSON ↔ YAML Converter
Convert JSON to YAML and YAML to JSON.