⭐ Click the star in your address bar to bookmark this page ×
Home Developer & Code Tools CSS Beautifier

CSS Beautifier — Format Stylesheets in Your Browser

Paste minified or messy CSS, pick your indent and spacing options, get clean readable code. Runs entirely in your browser — your code never leaves your device.

✓ Free Forever✓ No Signup✓ Runs Locally✓ One-Click Copy
styles.css
0 chars

What This Tool Does

The CSS Beautifier takes minified or sloppily-formatted CSS and rewrites it with proper indentation, newlines between rule blocks, and one selector per line where applicable. Paste, adjust options, click Beautify — the formatted result replaces your input.

It runs in your browser using the open-source js-beautify CSS engine. Your CSS never reaches a server — useful when you're working on private stylesheets, client codebases, or anything you'd rather not paste into a remote service.

The tool only touches whitespace and line breaks. It won't reorder rules, change property names, normalize colour formats, or modify specificity — every !important stays exactly where you put it. Purely cosmetic restructuring.

When to Use It

Reading minified production CSS. When you're inspecting a live site and pulling CSS from DevTools, you usually get a single long line. One beautify pass and you can actually see which selectors do what.

Cleaning up framework output. CSS that comes out of build pipelines, SASS compilers, or design-to-code tools is often correctly written but inconsistently formatted. Run it through here once and the whole file matches your team's style.

Pasted CSS that lost its formatting. CSS copied from a chat message, ticket, or PDF often arrives with broken line breaks. The beautifier reconstructs the structure.

Quick formatting before commit. When you don't have Prettier or Stylelint configured locally, this gives you the same clean output with a couple of clicks.

Step-by-Step

1

Paste your CSS

Any CSS — minified, mangled, or hand-written — works.

2

Set your indent size

2-space indent is the modern default (Airbnb, Google, and Prettier all use 2). Use tabs if your team prefers them.

3

Click Beautify

Or press Ctrl + Enter. The formatted code replaces your input in place.

4

Copy and paste back into your editor

The Copy button at the top of the editor pane sends the result to your clipboard.

What the Options Do (With Concrete Examples)

Newline between rule blocks. When on, each rule gets a blank line between it and the next — easier to scan in long stylesheets. When off, rules are packed tighter — more rules fit on screen. On is the standard.

Selector separator newline. When on, comma-separated selectors each get their own line: h1,
then h2,
then h3 {. When off, they all stay on one line: h1, h2, h3 {. The one-per-line form is far easier to scan when you have five or six selectors grouped together.

Preserve newlines. When on, your intentional blank lines between logical sections survive the beautify pass. When off, all blank lines are stripped. Most developers want this on — those section breaks are usually meaningful.

Max preserve newlines. Caps how many consecutive blank lines are kept. "Allow 2" means three or more blank lines in a row get collapsed to two — useful when you've inherited a file with random vertical padding.

What It Will and Won't Do

Will: fix indentation, add or normalize spacing inside declarations, separate rules onto new lines, split grouped selectors onto separate lines, collapse extra blank lines.

Won't: sort properties alphabetically, merge duplicate selectors, reformat colour values, remove unused rules, deduplicate properties, or fix syntax errors. For those, use a linter like Stylelint or a more aggressive tool like CSSO.

SCSS, SASS, LESS: partial support. Basic blocks format correctly, but nesting, mixins, variables, and other preprocessor-specific syntax may not be handled cleanly. Use a dedicated SCSS formatter for those.

Features

📐

Five Indent Sizes

Tabs or 2, 3, 4, or 8 spaces.

📋

Selectors Per Line

Split h1, h2, h3 onto separate lines, or keep them grouped.

⌨️

Keyboard Shortcut

Ctrl + Enter beautifies from anywhere.

🔒

Runs Locally

Nothing leaves your browser.

🔢

Live Character Count

See input/output size in real time.

🆓

Free Forever

No signup, no limits, no watermark.

Frequently Asked Questions

Will beautifying change how my page renders?
No. CSS ignores whitespace and indentation entirely — browsers parse body{margin:0} and body { margin: 0; } identically. The visual output of your page will be exactly the same.
Does it work with SCSS, SASS, or LESS?
Partially. Basic blocks and properties format correctly, but preprocessor-specific syntax — nesting, mixins, variables, parent selectors — may not be handled cleanly. For SCSS or LESS files, format them inside your editor with the appropriate plugin.
Is my CSS sent to a server?
No. The js-beautify library runs entirely in your browser. The library itself is loaded from a CDN once, but your CSS stays on your device. Open DevTools → Network and click Beautify — you'll see no outgoing requests.
Will it sort or deduplicate my CSS?
No. The beautifier only touches whitespace. Duplicate selectors, conflicting rules, and unused styles all survive untouched. For deduplication, use a tool like Stylelint or CSSO.
What about modern CSS — grid, custom properties, container queries?
All supported. CSS Grid, Flexbox, custom properties (CSS variables), @container, @layer, @supports, modern selectors like :has() and :is() — they all format correctly.
What indent size should I use?
Two spaces matches the most common modern style guides (Airbnb, Google, Prettier defaults). Four spaces is still common in older codebases. Tabs are correct if your project uses them — what matters most is consistency across the file, not which option you pick.