CSS / HTML / JS Code Minifier

Remove comments, collapse whitespace, strip redundant semicolons. See exact byte savings with a size comparison chart.

Minified output

Size comparison

What Minification Does

Minification removes everything that has no runtime effect: comments, unnecessary whitespace, and often optional syntax like trailing semicolons. It's the fastest performance win in any front-end stack — often 20–60% smaller files with zero functionality change.

What This Tool Removes

  • HTML — comments, whitespace between tags, redundant spaces in attribute values.
  • CSS — comments, whitespace, last semicolons in rule blocks, leading zeros on decimals.
  • JS — comments and whitespace (with full string-literal safety: single, double and template quotes are preserved exactly). Variable renaming is not performed — that requires a real minifier like Terser.

What Minification Won't Do

  • Rename variables (requires AST parsing)
  • Tree-shake unused code
  • Dead-code eliminate
  • Transform or transpile
  • Resolve CSS duplicate rules

For production builds, use the real tooling — Terser for JS, cssnano for CSS, html-minifier-terser for HTML. This tool is for quick one-off minification and byte-savings estimation.

Compression vs Minification

Minification and gzip/brotli compression are complementary. Minification reduces raw bytes; gzip then compresses the minified output. Always do both — minified + gzipped files are typically 15–25% of original size.

Safety Notes

The JS minifier preserves single-quoted, double-quoted and template-literal strings exactly, including escape sequences. Regex literals are treated as code — for regex-heavy code, manually verify output. Always diff before deploying.

Minifier FAQ

Will minifying break my code?

HTML and CSS: no, if well-formed. JS: the minifier here preserves all string literals safely. Regex-heavy code should be reviewed manually.

How much does minification save?

Typically 20–50% for HTML/CSS, 30–60% for JS. Combined with gzip, files often shrink to 10–20% of original.

Should I minify or gzip?

Both. Minification removes bytes; gzip compresses what's left. Always deploy minified + gzipped assets.

Is this as good as Terser?

No. Terser parses to an AST and renames variables — often 20–30% additional savings. This tool is a quick pass for one-off work.