NV ToolkitFormat · Validate · Convert

CSS Tools

CSS Formatter, Beautifier & Minifier

One stylesheet workspace, three engines: prettier for canonical formatting, js-beautify for unminifying broken bundles, and a minifier for the compact form — pick the mode in the rail.

In short

Format CSS with prettier, beautify minified or broken CSS with js-beautify, or minify it — three modes on one page, exact error positions, 100% in your browser.

By NaveenKumar T · Updated

Learn: Sass vs SCSS vs LESS vs Stylus: Choosing a CSS Preprocessor

  • Three modes: Format · Beautify · Minify
  • Real CSS parsing (prettier)
  • Forgiving js-beautify mode

Runs entirely in your browser — nothing you paste or open here is uploaded, logged, or stored.How we handle data →

Example

CSS Formatter: input and output

A navigation bar pasted straight out of a DevTools session: custom properties, a natively nested rule, an @layer block and inconsistent casing, all crammed together.

Input · css
:root{--nav-bg:#0F172A;--nav-fg:#F8FAFC;--gap:.75rem}
.navbar{display:flex;align-items:center;gap:var(--gap);padding:0 1.5REM;background:var(--nav-bg);color:var(--nav-fg)}
.navbar a{color:inherit;text-decoration:none;padding:1rem .5rem;
  &:hover{text-decoration:underline}
  &[aria-current=page]{font-weight:700;color:#FDE68A!important}
}
@layer overrides{.navbar .cta{background:#FDE68A;color:var(--nav-bg)}}
@media (max-width:640px){.navbar{padding:0 var(--gap)}}
Output · css
:root {
  --nav-bg: #0f172a;
  --nav-fg: #f8fafc;
  --gap: 0.75rem;
}
.navbar {
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 0 1.5rem;
  background: var(--nav-bg);
  color: var(--nav-fg);
}
.navbar a {
  color: inherit;
  text-decoration: none;
  padding: 1rem 0.5rem;
  &:hover {
    text-decoration: underline;
  }
  &[aria-current="page"] {
    font-weight: 700;
    color: #fde68a !important;
  }
}
@layer overrides {
  .navbar .cta {
    background: #fde68a;
    color: var(--nav-bg);
  }
}
@media (max-width: 640px) {
  .navbar {
    padding: 0 var(--gap);
  }
}

Every declaration lands on its own line with the nested &:hover and &[aria-current] blocks indented under .navbar a; the hex colors and the REM unit are lowercased, .75rem gains its leading zero, the attribute value is quoted, and !important is spaced.

Learn more

Formatting CSS properly

CSS formatting looks trivial until grid templates, custom properties, and nested at-rules arrive. This page runs prettier's postcss engine — the formatter most front-end repos enforce — so output here matches your toolchain: one declaration per line, consistent spacing, sensible wrapping for long values.

Because formatting parses the sheet, it doubles as a syntax check: a missing brace or stray semicolon reports its exact line instead of silently corrupting the cascade.

Modern CSS, handled

The engine keeps pace with the platform: native nesting, container queries, @layer cascade layers, :has() selectors, color-mix() and oklch() values, custom properties with fallbacks — all format correctly rather than tripping a parser frozen in 2015. That matters because modern sheets increasingly look like preprocessor code, and a formatter that mangles @layer ordering can genuinely change which rules win.

A practical workflow: paste the offending component's CSS from DevTools, format, read, fix, switch Mode to Minify and paste the compact form back. For stylesheets that live in a repo, match this page's output by running prettier with default options — they're the same defaults on purpose. When you need the minifier's before/after arithmetic and its caveats in detail, the dedicated CSS minifier page covers them.

Beautify mode: js-beautify for minified or broken CSS

Production CSS ships as a single line — perfect for transfer, useless for debugging. Beautify mode restores structure with js-beautify, the CSS printer behind the classic jsbeautifier.org, which re-indents tokens rather than building a full parse tree. That is the important difference from Format mode: js-beautify does not need the sheet to be valid. A stylesheet truncated mid-rule by a copy-paste, a fragment lifted out of DevTools with an unbalanced brace, or a bundle containing at-rules a strict parser rejects will still come back indented and readable instead of returning an error.

Beautify changes nothing but whitespace. Values are left byte-for-byte as written, declarations are never reordered, no shorthand is expanded or collapsed and hex colours keep their case — so a beautified third-party bundle can be diffed against the next release and the diff shows only what the vendor actually changed. Format mode is the opposite by design: prettier normalises tokens (lowercased hex and units, leading zeros, double quotes) because that is what a repo with prettier in CI expects. Use Format for source you own, Beautify for a bundle you are only reading.

Help

Frequently asked questions

Everything you need to know about the CSS Formatter.

01How do I use the CSS Formatter?

Paste your stylesheet (or load a file/URL), choose a Mode and press Format. Format runs prettier's CSS parser and re-prints in canonical style, reporting the exact position of anything it can't parse; Beautify runs js-beautify, which only re-indents and keeps working on truncated or minified CSS; Minify strips comments and whitespace and reports the byte saving in the status bar.

02Format or Beautify — which mode do I want?

Pick by what you are holding. Format runs prettier: it re-prints the sheet exactly the way a repo with prettier in CI expects, which also means it normalises values (lowercased hex and units, leading zeros, double-quoted strings) and refuses to format a sheet it cannot fully parse. Beautify runs js-beautify: it only re-indents, never rewrites a value, and keeps working on CSS that is truncated or slightly broken. Format for source you own, Beautify for a minified bundle or a fragment copied out of DevTools, Minify when you want the compact form back.

03Which values does the formatter rewrite, and which does it leave alone?

Prettier normalizes tokens without changing meaning: hex colors are lowercased (#FDE68A becomes #fde68a, inside custom properties too), bare decimals gain a leading zero (.75rem becomes 0.75rem), units are lowercased (6PX becomes 6px), single-quoted strings become double-quoted, attribute selector values are quoted, and !important always gets a space before it. It never reorders declarations or rules, never shortens colors, and leaves var() and calc() expressions intact apart from spacing around operators.

04Can I beautify a whole framework bundle?

Yes — multi-hundred-kilobyte sheets are fine, and js-beautify does not slow down on the aggressively minified output of Bootstrap or a Tailwind build. For very large bundles give the editor a second to render; the folding regions the editor adds keep navigation manageable afterwards. Because nothing is parsed into a tree, memory stays flat even on sheets that would make a strict formatter give up.

05Do comments and blank lines come back when I beautify a minified bundle?

Comments that survived minification — typically /*! license */ banners — are kept exactly where they appear; nothing the minifier already removed can be recovered. What you do get is structure: a blank line between rules so the blocks are visually separable, selector lists split one selector per line, each declaration on its own line, and @media and @keyframes blocks re-indented at whatever width you pick in the rail. What you do not get is anything the minifier deleted from inside a rule — the semicolon it dropped before each closing brace is not added back, because nothing but whitespace is changed here.

Keep working

Related tools

Learn the format

Related guides

All guides →