b2KIT

CSS Minifier

Minify CSS code by removing whitespace, comments, and redundant syntax to reduce file size.

Tested tool guide Tested browser tools Checked August 16, 2026

What CSS Minifier does, with a checked example

CSS Minifier turns readable CSS into a compact stylesheet by removing comments, collapsing unnecessary whitespace, and dropping syntax that CSS permits browsers to infer. Paste valid CSS and use the returned text as a production-oriented copy. A common surprise is that fewer source characters do not translate directly into the same reduction in network transfer size, since HTTP compression can narrow the difference. Minification also does not validate selectors, repair malformed declarations, or confirm that the stylesheet produces the intended design.

Worked example

A concrete input and expected output from the current implementation.

Input

a { color : red }

Expected output

a{color:red}

Every space in this rule is optional, and the final declaration already has no semicolon. Removing the formatting leaves the selector and declaration unchanged.

How the result is produced

1

Whitespace and comments

The minified form removes comment text and strips or collapses whitespace where CSS token boundaries remain unambiguous. Whitespace inside quoted strings is data and must not be treated as formatting. Token separation can also affect parsing, so CSS minification is more constrained than deleting every space and line break from the input.

2

Compact rule syntax

Rules and declarations are packed together, with optional spacing around braces, colons, semicolons, and commas removed. Redundant syntax, such as a final declaration separator when it can be omitted, may also disappear. The returned stylesheet preserves CSS rule meaning while discarding the indentation and line structure that made the source easier to scan.

Good uses

  • Preparing a hand-written stylesheet for a static production deployment where fewer source bytes are useful.
  • Compacting CSS copied into an inline style element after readable formatting is no longer needed.
  • Comparing readable and minified CSS to measure how much uncompressed space comments and formatting consume.

Limits and checks

  • A smaller result does not prove that the input was valid CSS or that its selectors match any document.
  • Because this tool removes comments, preserve required license notices or maintenance annotations outside the minified copy.
  • Uncompressed character reduction does not predict compressed network savings; gzip or Brotli can make the difference smaller.

Common questions

Will the minified CSS render exactly like the original?

That is the intended result for valid CSS: removing ordinary comments, formatting whitespace, and optional separators should not change the cascade or computed values. There is no reliable equivalence promise for malformed input because browser error recovery may differ from the compacted result. Test both versions when using unusual escapes, complex calculations, or custom-property token streams.

Can I minify Sass, SCSS, or Less directly?

No. This tool accepts CSS intended for browser parsing, not preprocessor source containing variables, mixins, interpolation, or other compile-time constructs. Compile Sass, SCSS, or Less into CSS first, then paste the generated stylesheet into the minifier. Otherwise, preprocessor-only syntax may be treated as invalid CSS rather than transformed correctly.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools