Skip to content
SmaftyTools

CSS Minifier & Beautifier

Minify CSS to shrink file size or beautify it into readable, indented code. Free online CSS formatter — instant and client-side.

About CSS Minifier & Beautifier

The CSS Minifier & Beautifier is a free css formatter that works in both directions: minify css online to strip comments and whitespace before shipping to production, or beautify a minified stylesheet back into cleanly indented, readable rules for debugging and code review. One tool, two everyday tasks, no separate pages to remember. It's a companion to the site's other formatting tools for anyone who works across the full front-end stack — HTML, CSS, JavaScript and the data formats that glue them together.

Minification reduces file size — typically 20–40% for hand-written stylesheets — which translates directly into faster page loads, less bandwidth and better Core Web Vitals scores like Largest Contentful Paint. Beautifying solves the opposite problem: you've been handed a single-line production stylesheet (from browser dev tools, a bundler's build output, or a vendor's CDN file) and need to actually read it to find a specific rule or debug a layout issue. Running it through the css beautifier turns that wall of text back into normal, indented CSS in one click. The beautifier is also useful when learning from someone else's code: expanding a competitor's or a library's minified stylesheet lets you study exactly how a particular effect — a complex grid layout, an animation, a print stylesheet — was actually built, without needing access to their original source files.

The formatter understands nested at-rules like @media and @supports, keeping their block structure intact rather than flattening them, and preserves selector and property order exactly — nothing about how your styles are applied changes, only how the text looks. Comments are stripped along with trailing semicolons and extra whitespace between selectors when minifying, all of which add up in a large stylesheet; when beautifying, indentation and line breaks are reintroduced consistently so nested rules and media queries are easy to follow at a glance.

Both directions run instantly and entirely client-side, so proprietary stylesheets and unreleased design work never leave your machine. For teams that lint or format CSS automatically in CI, this tool is also a quick way to preview what the formatted output should look like before configuring a build step to do it automatically.

How to Use the CSS Minifier & Beautifier

  1. Choose Beautify or Minify mode.
  2. Paste your CSS into the input pane.
  3. Copy the formatted result from the output pane.

Features

  • Two-way: minify for production, beautify for readability
  • Strips comments and collapses whitespace when minifying
  • Handles nested at-rules like @media
  • Instant, client-side processing

Examples

Minifying a stylesheet for production

Input

.card {
  padding: 16px;
  border-radius: 8px;
}

.card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

Output

.card{padding:16px;border-radius:8px}.card:hover{box-shadow:0 2px 8px rgba(0,0,0,0.1)}

Beautifying a minified stylesheet for debugging

Input

.btn{color:#fff;background:#0070f3}.btn:hover{background:#0059c1}

Output

.btn {
  color: #fff;
  background: #0070f3;
}

.btn:hover {
  background: #0059c1;
}

Frequently Asked Questions

How much smaller does minified CSS get?

Typically 20–40% for hand-written CSS, depending on how many comments and how much whitespace it contains. Combined with gzip on your server, the delivered size drops further.

Does minifying change how my styles work?

No. Only comments and unnecessary whitespace are removed — selectors, properties and values are untouched, so the stylesheet behaves identically.

Will minifying break CSS custom properties (variables)?

No. Custom properties (--variable-name) and their var() usages are left completely intact — only comments and formatting whitespace are removed.

Is the CSS formatter free?

Yes, the CSS formatter is completely free with no usage limits. No signup, no account and no installation required.

Is my data safe?

Yes. All processing happens locally in your browser using JavaScript — nothing you type is uploaded or stored on our servers.