ToolNimba Browse

🎨 CSS Minifier

By ToolNimba Web Dev Team · Updated 2026-06-19

Minified CSS
 
Paste CSS above, then press Minify CSS to see the savings.

This CSS minifier shrinks a stylesheet by removing everything a browser does not need to render it: comments, line breaks, indentation, and the spaces sitting around braces, colons, semicolons, and commas. Paste your CSS, press Minify, and you get a single compact block plus a readout of the original size, the minified size, and the percentage you saved. Everything runs in your browser, so your code is never uploaded anywhere.

What is the CSS Minifier?

Minification is the process of stripping characters that exist only for human readability and have no effect on how a stylesheet behaves. A browser does not care whether a rule sits on one line or twenty, or whether there is a space after a colon. Those characters still cost bytes, and bytes cost download time. By removing comments, collapsing every run of whitespace down to nothing or a single space, and deleting the spaces around structural punctuation such as the braces, colon, semicolon, and comma, a minifier can often cut a hand-written stylesheet by 20 to 50 percent before any further compression is applied.

Smaller CSS matters for page speed and for Core Web Vitals. CSS is render-blocking, which means the browser will not paint the page until it has downloaded and parsed the stylesheets in the head. The fewer bytes it has to fetch, the sooner the first paint can happen, especially on slow mobile connections. Minified CSS also compresses well over the wire: when your server sends files with Gzip or Brotli, a minified file is already free of the repetitive whitespace that compression would otherwise have to handle, so the transferred size drops further still.

This tool performs safe, structural minification. It does not rename your classes, reorder declarations, merge duplicate rules, or rewrite color values, because those transformations can change behaviour or specificity in subtle ways. It sticks to the changes that are always safe: dropping comments (unless you ask to keep them), removing redundant whitespace, and deleting the final semicolon before a closing brace. The result is byte-for-byte equivalent CSS that a browser parses exactly as it did your original file.

When to use it

  • Shrinking a production stylesheet before deploying a static site or landing page.
  • Cleaning up CSS copied from a tutorial or generator so it pastes compactly into a project.
  • Reducing the size of inline critical CSS placed in the head of a document for faster first paint.
  • Checking how much weight a stylesheet carries by comparing the original and minified byte counts.

How to use the CSS Minifier

  1. Paste or type your CSS into the input box.
  2. Leave Keep comments unchecked to strip them, or tick it to preserve them.
  3. Press Minify CSS to generate the compact output.
  4. Read the size summary to see the bytes and percentage saved.
  5. Press Copy to put the minified CSS on your clipboard.

Formula & method

saved% = (originalBytes - minifiedBytes) / originalBytes * 100. Bytes are measured as UTF-8 encoded length, the same way a server reports file size.

Worked examples

A small rule with a comment, extra spaces, and a trailing semicolon.

  1. Input: /* main */ body { margin: 0; color: #fff ; }
  2. Remove the comment block /* main */
  3. Collapse whitespace and remove spaces around { } : ;
  4. Drop the trailing semicolon before the closing brace
  5. Output: body{margin:0;color:#fff}

Result: From 44 bytes down to 25 bytes, a saving of about 43%.

Two selectors sharing a block with padded spacing.

  1. Input: .box , .card { padding: 10px 20px ; }
  2. Collapse the spaces around the comma and the braces
  3. Remove the space before the trailing semicolon, then drop that semicolon
  4. Preserve the single space inside the value 10px 20px, since it is meaningful
  5. Output: .box,.card{padding:10px 20px}

Result: The selector list and value stay valid while every redundant space is removed.

What CSS minification removes and what it keeps

Character or tokenActionWhy
Block commentsRemoved by defaultComments never affect rendering
Line breaks and indentationRemovedWhitespace between tokens is optional
Spaces around braces, colon, semicolon, commaRemovedNot required by the CSS grammar
Trailing semicolon before }RemovedThe last declaration does not need one
Single space inside a value (10px 20px)KeptIt separates two distinct values

Common mistakes to avoid

  • Minifying the file you also edit. Always keep your readable source file and minify a copy for production. Editing minified CSS by hand is painful and error prone, so treat the minified output as a build artefact, not your master file.
  • Stripping comments that carry a license. Some libraries require their license banner to stay in the file. If your CSS includes a legal notice, tick Keep comments so the banner is preserved rather than removed.
  • Expecting minification to fix invalid CSS. A minifier only removes redundant characters, it does not repair broken syntax. If a brace is missing or a property is misspelled, the minified output will carry the same error.
  • Assuming minified equals fully optimized. This tool removes whitespace and comments but does not merge duplicate rules, drop unused selectors, or shorten color values. For deeper optimization, also remove dead CSS and let your server apply Gzip or Brotli.

Glossary

Minification
Removing characters that are not needed for a browser to parse and render code, such as whitespace and comments.
Whitespace
Spaces, tabs, and line breaks. In CSS most whitespace between tokens is optional and can be removed.
Render-blocking
A resource the browser must load before it can paint the page. CSS in the head is render-blocking.
Gzip and Brotli
Compression methods a web server uses to shrink files in transit. They work best on already minified files.
Critical CSS
The small subset of CSS needed to style content visible on first load, often inlined in the head for speed.

Frequently asked questions

What does a CSS minifier do?

It removes characters a browser does not need, including comments, line breaks, indentation, and the spaces around braces, colons, semicolons, and commas. The result is a smaller file that renders exactly the same as your original CSS.

Does minifying CSS change how my site looks?

No. This tool only strips redundant whitespace and comments and the optional trailing semicolon. It does not touch your selectors, properties, or values, so the browser parses the minified CSS identically to the original.

How much smaller will my CSS get?

It depends on how much whitespace and commenting the original file has. Hand-written, well-indented CSS often shrinks by 20 to 50 percent. The tool shows the exact byte count and percentage saved after you minify.

Can I keep my comments?

Yes. Tick the Keep comments box before pressing Minify. This is useful when a stylesheet includes a license banner that must remain in the file, since whitespace will still be collapsed around the comment.

Is my CSS uploaded to a server?

No. The minifier runs entirely in your browser using plain JavaScript. Your CSS never leaves your device, which makes it safe to use with private or proprietary stylesheets.

Should I still compress minified CSS on my server?

Yes. Minification and server compression work together. Minified CSS is already free of repetitive whitespace, and applying Gzip or Brotli on top shrinks the transferred size even further for visitors.