Home/Developer Tools/CSS Formatter, Minifier & Validator

CSS Formatter, Minifier & Validator

FREE

Beautify, minify or find the unbalanced brace in a stylesheet

Free · No sign-up required
Loading...

What the CSS formatter does

Three operations on a stylesheet: beautify a minified or messy file into consistently indented, one-declaration-per-line CSS; minify it by stripping comments and whitespace for production; and validate it, reporting unbalanced braces, missing semicolons and malformed declarations with line numbers. Everything runs in your browser, so stylesheets from private projects stay on your machine.

Beautify: before and after

Before (minified): .card{display:flex;gap:12px;padding:16px}.card:hover{box-shadow:0 4px 12px rgba(0,0,0,.1)}@media(max-width:640px){.card{flex-direction:column}} After: .card { display: flex; gap: 12px; padding: 16px; } .card:hover { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); } @media (max-width: 640px) { .card { flex-direction: column; } }

What each mode changes

ModeChangesKeeps
BeautifyIndentation (2 spaces), line breaks, spacing around colons and braces, one declaration per line, blank line between rulesSelector text, property order, values, comments, vendor prefixes
MinifyRemoves comments, whitespace, final semicolons in blocks; collapses spaces in valuesEvery rule and declaration — the output is functionally identical
ValidateNothing — reports issues only

Neither beautify nor minify changes what the CSS does. They do not reorder properties, merge selectors, remove unused rules or rewrite values — those are optimisation tasks for tools like cssnano or PurgeCSS in a build pipeline.

What the validator catches

  • Unbalanced { and } — the most common cause of “everything after line N stopped working”.
  • Missing semicolons between declarations (the last one in a block is optional).
  • Declarations without a colon, or with an empty value.
  • Unclosed comments (/* without */), which silently swallow the rest of the file.
  • Unclosed strings and url() parentheses.

It checks syntax, not semantics: colr: red is syntactically fine and will pass, as will a valid property with a value the browser does not understand. For property and value checking, use the W3C CSS Validator or a linter such as Stylelint.

When to minify

Minification saves 15–30% on typical CSS before gzip and a few percent after — modest, because gzip already removes most whitespace redundancy. It is still standard practice in production builds, mainly to strip comments (which can contain internal notes) and to shave bytes on the critical path. Keep the formatted source in version control and generate minified output in the build; never edit minified files.

Common uses

  • Reading a third-party or legacy stylesheet that shipped minified.
  • Cleaning up CSS pasted from a CMS, an email template or a browser's computed styles.
  • Finding the missing brace that broke a page.
  • Producing a minified snippet to inline in a <style> tag or an HTML email.
  • Normalising formatting before a code review so the diff shows only real changes.

Frequently asked questions

Does it support SCSS or Less?

It handles plain CSS. Nested SCSS blocks will beautify reasonably but validation will flag preprocessor syntax as errors. Use the preprocessor's own formatter for source files.

Will it remove my vendor prefixes or unused rules?

No. It changes only formatting. Autoprefixer and PurgeCSS handle those in a build pipeline.

Why does the minified output still work when the last semicolon is gone?

The final declaration in a block does not need a semicolon; the closing brace ends it. Removing it is safe and standard.

Can I choose tabs or 4-space indentation?

Not in this tool; output uses 2 spaces. Editors such as VS Code (Format Document) and Prettier offer configurable styles.

Does minifying change colours like #ffffff to #fff?

No. Value rewriting is an optimisation step this tool does not perform, to guarantee the output is byte-for-byte equivalent in meaning.

Is my CSS uploaded?

No. Formatting, minifying and validation run in your browser.

More tools in this category

🌈
CSS Gradient Generator
Build linear, radial and conic gradients and copy the CSS
🪟
CSS Glassmorphism Generator
Frosted-glass panels with backdrop-filter, tint and border
CSS Clip-Path Generator
Circle, polygon, star and custom shapes as clip-path values
📈
CSS Cubic-Bezier Generator
Drag handles to design easing curves for transitions
CSS Loader Generator
Spinner, dots, bars, pulse and bounce loaders in pure CSS
🖱
CSS Button Generator
Design buttons with hover, active and focus states