CSS Minifier
Compact CSS with a real parser while preserving rule order, strings and custom properties, and measure the output size.
Your CSS
Up to 256 KiB measured as UTF-8. Processing runs in a disposable local Web Worker.
CSS Tree parses and reprints CSS. Rule order, raw custom properties and important /*! comments */ are retained; this is not a full browser/property validator. Libraries load from this site only when you run the tool.
Minified output
Understand your results
For developers preparing a smaller plain-CSS file while keeping its rule and declaration order.
CSS Tree parses the stylesheet into an abstract syntax tree and generates compact CSS. Token-aware checks catch incomplete strings, URLs, comments and bracket pairs before parsing; parser recovery errors are surfaced rather than silently accepted. The tool does not merge selectors, reorder declarations, change colours or discard unused rules. Raw custom-property values and important exclamation comments are retained conservatively.
How to use this tool
- Paste a complete plain-CSS stylesheet, without HTML style tags or preprocessor syntax.
- Run Minify CSS. The parser loads only for this action and runs inside a disposable local browser worker.
- Review measured UTF-8 original/output bytes and reduction, then copy or download the complete .css output and test it in your site.
What the observations mean
The reported percentage is measured from the actual input/output UTF-8 strings. Compact CSS can remain large when custom-property or unfamiliar raw token content is intentionally preserved. Byte reduction alone does not establish rendering speed or Core Web Vitals.
Worked example
Compact a rule while keeping comment-like characters in its string and custom-property data.
.card {
content: "A /* literal */ string";
--gap: 12px;
width: calc(100% - var(--gap));
}Output removes unnecessary stylesheet formatting without treating the string's /* literal */ as a comment. Raw --gap data and required calculation spacing are preserved. The UI computes the reduction from the actual UTF-8 output rather than promising a preset percentage.
Limits and processing
CSS Tree 3.2.1 parsing/compact generation, not full browser validation or semantic optimization. Maximum 256 KiB UTF-8, 100 nesting levels and a 12-second browser-worker deadline. Legal comments/raw custom-property content can remain. No imports, URLs or styles are fetched or applied.
Common problems and practical fixes
- A syntax or bracket error appears
- Supply balanced, complete plain CSS. Parser-recovery errors and unterminated tokens are not silently repaired.
- Variables or URL text look unchanged
- Raw custom properties and literal string/URL content need faithful handling, so they are preserved rather than stripped using text substitutions.
- Output grows or savings are small
- Already compact input may not shrink. Check measured bytes; no fixed compression percentage is promised.
Best practices
Keep the original source and compare behavior in the target browsers. Use this conservative minifier alongside, rather than as a substitute for, your tested production build pipeline.
Practical tips
- Strings and URLs can contain comment-like characters; a parser distinguishes these from actual comments.
- Custom-property whitespace and comments can be meaningful token data, so their raw values may stay larger than expected.
- Minification does not replace gzip/Brotli, critical-CSS decisions or testing across browsers.
Frequently asked questions
Practical answers for using the CSS Minifier.
Why are some comments still present?
Important /*! comments */ are retained. Comments inside raw custom-property values or unsupported/raw syntax can also remain to avoid changing token meaning.
Does a parse pass prove the CSS works everywhere?
No. Parsing is not a full property-value or browser-compatibility check. New syntax outside the parser's support may be rejected; keep and test your original stylesheet.
How is reduction calculated?
The tool measures UTF-8 bytes before and after processing, then calculates (original − output) / original × 100. This is not network transfer compression; a negative result means the output grew.