200 tools

Web Developer Tools · · 3 min read

How to Minify CSS to Shrink Stylesheet File Size

Use the CSS Minifier to strip comments and whitespace from CSS instantly in your browser, with a real before-and-after example.

To minify CSS, paste your stylesheet into the CSS Minifier and read the compacted result immediately in the output box — it strips comments and collapses all unnecessary whitespace with no button to click.

What the CSS Minifier does

Hand-written or beautified CSS is full of things a browser doesn't need to parse your rules: comments, line breaks, indentation, and extra spaces around selectors, braces, and property values. None of that affects how the stylesheet renders a page — it's there purely to make the source readable for people. The CSS Minifier removes it: it deletes every /* ... */ comment, collapses all whitespace down to single spaces, then removes the spacing around punctuation like {, }, ;, ,, >, and ~ entirely, removes the space after colons in declarations, and drops the final semicolon before a closing brace. The result is the same CSS, just smaller, running entirely in your browser.

How to minify CSS with Toolbench

  1. Open the CSS Minifier.
  2. Paste your CSS into the input box on the left.
  3. Read the minified output on the right — it updates instantly as you type or paste, with no settings to configure and no "Minify" button to press.
  4. Click Copy to grab the result, or use the Send to → menu to pass the output into another tool, such as the CSS Beautifier if you need to check it's still valid.

There's nothing to configure here — the CSS Minifier runs the same transform on every input, so pasting is the whole workflow.

A real worked example

Starting from this commented, indented CSS:

/* card */
.card {
  color: #333;
  margin: 0 auto;
}

The CSS Minifier produces:

.card{color:#333;margin:0 auto}

The /* card */ comment is gone, the newlines and indentation have collapsed away, the space before { and after : is removed, and the trailing semicolon before the closing } is dropped — but margin: 0 auto keeps the space between 0 and auto, since that space is part of the value itself, not formatting whitespace.

What gets removed vs. what stays

Removed Kept
/* ... */ comments Selectors, property names, and values exactly as written
Line breaks and indentation Spaces inside values (e.g. 0 auto, 1px solid #ddd)
Spaces around {, }, ;, ,, >, ~ Units, colors, and vendor prefixes
The space after a colon in a declaration @media query conditions and nested rules
The last semicolon before a closing } String content inside quotes

Tips and common mistakes

  • It won't catch invalid CSS. The minifier only strips comments and whitespace — it doesn't validate selectors or balance braces, so a syntax error going in is still a syntax error coming out, just harder to spot.
  • Minifying is one-way for comments. Comments are deleted, not hidden, so you can't get them back by running the output through the CSS Beautifier. Keep your commented source file separately if you'll need to edit it again later.
  • Already minifying CSS inside an HTML file? Use the HTML Minifier instead — its "Minify <style> blocks" option runs this same CSS minifier on any <style> tags it finds, so you don't need to extract the CSS by hand.
  • Going the other way? If you're handed minified CSS and need to read or edit it, paste it into the CSS Beautifier to reformat it with proper indentation.
  • CSS Beautifier — the inverse: turn minified or cramped CSS back into readable, indented rules.
  • HTML Minifier — strip comments and whitespace from HTML, including any embedded <style> blocks.
  • JavaScript Beautifier — format JavaScript if your page also ships minified scripts you need to read.
  • Color Converter — convert hex, RGB, or HSL colors before they go into your stylesheet.

Frequently asked questions

How do I minify CSS?

Paste it into the CSS Minifier. It strips comments and whitespace instantly, with no button to click and no account needed.

Does minifying CSS change how my page looks?

No. Minifying only removes comments and formatting whitespace — selectors, property names, values, and units are untouched, so the stylesheet applies identically before and after.

Will it fix invalid CSS or balance missing braces?

No. The minifier only removes comments and whitespace; it doesn't validate or repair the structure of your CSS.

Can I get my comments back after minifying?

No. Comments are deleted, not stored anywhere. Keep a copy of your original, commented CSS if you'll need to edit it later.

Is my CSS sent to a server?

No. Minifying runs entirely in your browser. If you're signed in, your input syncs privately to your account; if you're signed out, nothing is saved anywhere.

More guides

All guides →