FormatterHQ

CSS Formatter & Beautifier

Unminify and indent CSS: one declaration per line, selectors split at commas, nested @media and @supports blocks indented. Minify again with one click.

Input CSS
Output CSS
Ready.

How to use the CSS Formatter

  1. Paste your CSS into the Input editor, or use Sample, Upload file or Load URL to load a stylesheet.
  2. Choose an Indent and whether to add a Blank line between rules.
  3. Press Beautify to format, or Minify to compress the stylesheet.
  4. Use Copy or Download above the output panel to take the stylesheet with you.

A CSS formatter for minified stylesheets

Minified CSS from a CDN or a production build is compact but unreadable. This CSS formatter, built on js-beautify's CSS beautifier, expands it back into a conventional layout: each selector on its own line, one declaration per line, and nested at-rules indented. It is tolerant of unusual input, so vendor hacks, custom properties and unknown at-rules pass through unchanged.

Example

a,button{color:#333;transition:color .2s ease}a:hover,button:focus-visible{color:#0f766e}@media (prefers-color-scheme:dark){a{color:#ddd}}
a,
button {
    color: #333;
    transition: color .2s ease
}

a:hover,
button:focus-visible {
    color: #0f766e
}

@media (prefers-color-scheme:dark) {
    a {
        color: #ddd
    }
}

The example uses a 4-space indent. Selector lists are split at commas, a space follows each colon, and rules are separated by blank lines. As with all js-beautify output, the formatter only changes whitespace: it does not add the final semicolon that minifiers remove, does not add the leading zero to .2s, and does not add a space inside the media query. Your values arrive exactly as written.

Options

  • Indent – 2 spaces (default), 3, 4, 8 or tabs.
  • Blank line between rules – on by default. Turn it off for a denser file where each rule directly follows the previous one; this is handy for short utility stylesheets.
  • Minify – removes whitespace and comments to produce a single line. For structural optimizations such as merging duplicate rules and shortening colors, use the CSS Minifier.

Common CSS conventions

Most CSS style guides agree on the basics this formatter applies: one selector per line in a list, one declaration per line, a space after the colon, and an opening brace on the selector's line. A few conventions go beyond whitespace and are worth adopting by hand:

  • End every declaration with a semicolon, including the last one, so adding a line later cannot break the rule.
  • Write lowercase hex colors and keep units off zero values (margin: 0).
  • Group related properties: positioning, box model, typography, visual effects.
  • Keep specificity low; prefer a class over #id or chained selectors.

If you want semicolons, leading zeros and lowercase colors applied automatically, CSS Pretty Print runs Prettier, which normalizes those details.

Common CSS errors this makes visible

  • A missing closing brace makes every following rule indent one level too deep. The point where the indentation drifts is where the brace is missing.
  • A missing semicolon joins two declarations into one invalid value, e.g. color: red background: blue; after formatting they appear on one line where you would expect two.
  • Unclosed comments swallow the rest of the file into a comment.

For a precise report with line numbers and warnings about unknown properties and invalid values, check the file with the CSS Validator.

Reading CSS from a live site

If a site ships source maps (a /*# sourceMappingURL=... */ comment at the end of the file), your browser's developer tools can show the original source files. Many production sites do not publish them, and then formatting is the quickest way to read the rules. Load URL fetches a stylesheet by its address, and Beautify turns it into something you can search, copy from and compare with your own styles.

Preprocessor files

The beautifier handles plain CSS best. SCSS and LESS files with nesting, mixins and variables are better served by the SCSS Formatter or the LESS formatter, which understand the preprocessor syntax. Everything runs locally in your browser.

Frequently asked questions

Does the CSS formatter change my values?
No. It only adds or removes whitespace and line breaks. Colors, units, missing trailing semicolons and vendor prefixes stay as written.
Can I unminify a CSS file from a website?
Yes. Use Load URL or paste the minified code and press Beautify. You get readable rules again, although removed comments cannot be recovered.
How do I remove the empty lines between rules?
Uncheck Blank line between rules. Each rule then follows the previous closing brace directly.
Does it support CSS custom properties and modern syntax?
Yes. Custom properties, @container, @layer, :is() and :has() selectors are passed through and indented like any other rule.
Why is the last semicolon missing in a rule?
Minifiers remove the final semicolon because it is optional, and this formatter does not add it back. CSS Pretty Print adds semicolons if you want them.

Last updated September 26, 2026

Related tools

CSS Animation Generator Generate CSS @keyframes animations — fade, slide, zoom, bounce, pulse, shake, spin and more — with duration, delay, easing and loop controls. CSS Background Pattern Generator Generate repeating CSS background patterns — stripes, polka dots, checkerboard, grid, zigzag and more — using only gradients, no images. CSS Border Radius Generator Set border-radius per corner in px or %, or shape organic blobs with the 8-value "fancy" border-radius syntax. Live preview and copyable CSS. CSS Box Shadow Generator Design layered CSS box-shadows with sliders for offset, blur, spread, colour and opacity. Supports inset shadows, presets and a Tailwind class. CSS Button Generator Design a CSS button with colours, gradient, padding, radius, border, shadow and hover/focus states, then copy clean HTML and CSS. CSS Clamp Generator (Fluid Typography) Calculate a CSS clamp() value that scales font size or spacing smoothly between two viewport widths, with a table of computed sizes. CSS Gradient Generator Create linear, radial and conic CSS gradients visually with draggable colour stops, presets and a live preview, then copy the CSS or Tailwind class. CSS Grid Generator Build CSS grid layouts: fixed or responsive auto-fit columns, row sizes, gaps and alignment, with a live grid preview and copyable CSS + HTML. CSS Loader & Spinner Generator Create lightweight pure-CSS loading spinners — ring, dual ring, bouncing dots, bars and pulse — with custom colour, size and speed. CSS Pretty Print Opinionated CSS pretty print with Prettier: normalises case, leading zeros, quotes and semicolons so a team's stylesheets look alike. CSS Scrollbar Generator Style scrollbars for Chrome, Edge and Safari (::-webkit-scrollbar) and Firefox (scrollbar-color) at once, with a scrollable live preview. CSS Gradient Text Generator Fill headings with a colour gradient using background-clip: text. Pick two or three colours and an angle and copy cross-browser CSS.