Code Minifier
Minify and compress JavaScript, HTML, and CSS code online with Terser engine. Reduce payload size by up to 70%.
How do I use Code Minifier?
Paste HTML, CSS, or JavaScript source code into the editor or click "Load Sample Data".
Select language mode (`Auto`, `HTML`, `CSS`, or `JS`) and toggle comment stripping or whitespace collapse.
Inspect the byte reduction metrics and copy or download the minified production output.
What features does Code Minifier offer?
Terser JS minification engine with mangling and dead code elimination
CSS & HTML comment stripping & whitespace collapsing
Live compression ratio & percentage saved metrics
100% client-side privacy guarantee — zero server uploads
Web Asset Minification & Compression Benchmarks
Compares AST token compression ratios before and after Brotli (RFC 7932) transport encoding.
| Asset Type | AST Transformation Applied | Raw Minified Savings | Minified + Brotli-11 Savings |
|---|---|---|---|
| JavaScript (ES2022) | Identifier mangling, dead-code elimination, whitespace removal | 35% – 55% | 78% – 85% |
| CSS3 Stylesheets | Shorthand merging, hex color 6→3 char folding, comment stripping | 25% – 45% | 82% – 88% |
| HTML5 Markup | Inter-tag whitespace collapse, optional closing tag removal | 15% – 30% | 75% – 84% |
| Inline SVG inside HTML | Path precision rounding, metadata & XML comment removal | 40% – 65% | 80% – 90% |
Frequently Asked Questions about Code Minifier
Why does collapsing whitespace in HTML sometimes break inline layout spacing?
HTML treats newlines between inline elements (`<span>`, `<a>`) as a single space character (`U+0020`). Aggressive whitespace collapse removes this gap unless `conservativeCollapse` is maintained around inline display tags.
Are license comments (`/*! ... */`) preserved during CSS and JS minification?
Standard block comments (`/* ... */`) and line comments (`//`) are stripped to save bytes, while legal bang-comments (`/*! ... */`) can be retained depending on your comment preservation toggle.
Can CSS minification break `calc()` expressions?
CSS `calc()` requires explicit spaces around `+` and `-` operators (e.g., `calc(100% - 20px)`) so the parser distinguishes subtraction from negative numbers (`-20px`). Our CSS tokenizer preserves mandatory spaces inside `calc()`, `min()`, `max()`, and `clamp()`.
What is the maximum file size supported for in-browser code minification?
The client-side engine processes files up to 10 MB without server round-trips. Bundles larger than 2 MB execute asynchronously to avoid blocking the browser UI main thread.
Explore Related Developer Tools
JavaScript Minifier
Minify and compress JavaScript files online with Terser engine. Mangle variable names and drop console logs.
Code Formatter
Format and beautify JavaScript, TypeScript, HTML, CSS, and Python code online with Prettier engine.
HTML to React JSX
Transform raw HTML snippets into valid React JSX/TSX components. Auto-converts class to className and style objects.
TypeScript & TSX Code Formatter
Format and beautify TypeScript (.ts) and React TSX (.tsx) code locally in your browser using the Prettier TypeScript AST parser.
Color Palette Generator
Generate HSL color harmonies (Monochromatic, Analogous, Complementary) and Tailwind CSS 10-shade scale palettes online.
WCAG Contrast Checker
Calculate relative luminance and test WCAG 2.1 AA/AAA text accessibility contrast ratio compliance online.