DoneInTab

CSS Minifier & Formatter

Minify stylesheets to reduce file size and accelerate website page speed. Safely handles modern CSS features including calc() spacing, custom properties, @container queries, cascade layers, and nesting. 100% private and client-side.

Drop a .css file here, or click to browse

Or paste your stylesheet directly into the editor below

Optimization Rules:
0 chars • 0 B
0 chars • 0 B

Why Syntax-Aware CSS Minification Matters

Pitfalls of Naive Regex Minifiers

Many simple online tools apply naive regex expressions that blindly strip all spaces and comments. In CSS, whitespace is often semantically required:

  • Math Operators: calc(100% - 20px) requires spaces around the minus sign. Stripping them invalidates the declaration.
  • Descendant Combinators: .header .title requires a space. Without it, .header.title targets an entirely different element.
  • Strings & Data URIs: Comments or hashes inside content: "/* text */" or SVG data URLs must be preserved verbatim.

Performance & Bandwidth Savings

Minifying CSS produces measurable real-world performance benefits:

  • Faster Time to First Render: CSS is a render-blocking resource. Smaller stylesheet payloads parse and apply faster in the browser.
  • Lower Bandwidth: Typical stylesheets see a 20% to 50% byte reduction from stripping comments, whitespace, and formatting indentation.
  • Gzip & Brotli Friendly: Normalized, minified syntax compresses even more efficiently when served over HTTP compression.

Frequently Asked Questions

How does CSS minification reduce file size?

CSS minification strips unnecessary whitespace, indentation, newlines, and non-essential comments from your stylesheet. It also eliminates redundant semicolons and collapses selector syntax where permitted by the CSS specification, reducing total byte weight and speeding up browser network transfer.

Why is whitespace preserved inside calc() and math functions?

The W3C CSS Values and Units specification explicitly mandates whitespace around '+' and '-' operators in math functions like calc(), min(), max(), and clamp(). For example, 'calc(100% - 20px)' is valid CSS, whereas 'calc(100%-20px)' is invalid syntax because the negative sign is parsed as an identifier prefix rather than a subtraction operator. Our tokenizer preserves these critical spaces.

Does this minifier support modern CSS like @container, @layer, and nesting?

Yes. Our tokenizer-based engine parses modern CSS features including cascade layers (@layer), container queries (@container), CSS nesting (& .selector), and custom properties (--var: ...) safely without dropping declarations or mangling structure.

Are my stylesheets uploaded or processed on external servers?

No. The minification and formatting processes execute 100% client-side in your local browser memory using JavaScript. No files or styles are transmitted over the network or logged.

Can I preserve copyright and license comments?

Yes. By default, 'Preserve Important Comments' is enabled, which retains all comments starting with '/*!' (the standard convention for open-source licenses, authors, and copyright notices) while removing all other comments.

Related Developer Utilities