JavaScript Minifier
Minify and compress JavaScript files online with Terser engine. Mangle variable names and drop console logs.
How do I use JavaScript Minifier?
Paste ES6+/TypeScript-compiled JavaScript source code or click "Load Sample Data".
Toggle identifier mangling, console statement removal, and dead-code elimination options.
Review the byte savings ratio and copy the minified `.min.js` production code.
What features does JavaScript Minifier offer?
Terser JS minification engine with variable mangling & drop_console options
Live file size reduction & percentage saved metrics
Estimated Gzip payload size calculation
100% client-side local browser execution — zero data uploads
ECMAScript AST Minification & Mangling Rules
Summarizes safe vs unsafe AST optimizations applied during JavaScript minification.
| Optimization Pass | Input Code Example | Minified Output | Side-Effect Risk |
|---|---|---|---|
| Boolean Literal Shortening | const active = true; const off = false; | const active=!0,off=!1; | Zero (100% Spec-Safe) |
| Undefined Substitution | if (x === undefined) return; | if(void 0===x)return; | Zero (Prevents shadowing) |
| Constant Folding | const ttl = 60 * 60 * 24 * 1000; | const ttl=864e5; | Zero (IEEE 754 exact) |
| Local Identifier Mangling | function calcTotal(priceValue) {} | function calcTotal(a){} | Safe unless Function.toString() used |
| Property Mangling | obj._internalState = 1; | obj.a=1; | High (Breaks JSON/Reflection) |
Frequently Asked Questions about JavaScript Minifier
Why does the minifier replace `true` with `!0` and `undefined` with `void 0`?
`!0` is 2 bytes instead of 4 bytes (`true`), and `void 0` is 6 bytes instead of 9 bytes (`undefined`). Furthermore, `undefined` is not a reserved keyword in non-global scopes and could theoretically be shadowed, whereas `void 0` is immutable.
Will identifier mangling break Angular or React component names in DevTools?
Mangling local function arguments and scoped variables is completely safe, but mangling top-level class or function names alters `Function.prototype.name`. Enable `keep_fnames` if your framework relies on runtime function reflection.
How does Automatic Semicolon Insertion (ASI) affect single-line minification?
Removing newlines without inserting explicit semicolons causes syntax errors or unintended function invocations (e.g., `(function(){})()`). The AST emitter explicitly inserts semicolons before stripping line breaks.
Are ES2022 private class fields (`#field`) and optional chaining (`?.`) supported?
Yes, modern ECMAScript syntax including optional chaining (`?.`), nullish coalescing (`??`), BigInt literals (`100n`), and private class members (`#prop`) are parsed and preserved natively.
Explore Related Developer Tools
Code Minifier
Minify and compress JavaScript, HTML, and CSS code online with Terser engine. Reduce payload size by up to 70%.
Code Formatter
Format and beautify JavaScript, TypeScript, HTML, CSS, and Python code online with Prettier engine.
TypeScript & TSX Code Formatter
Format and beautify TypeScript (.ts) and React TSX (.tsx) code locally in your browser using the Prettier TypeScript AST parser.
.env File Editor
Visual editor for .env files — parse, validate, detect duplicate keys, mask secrets, and generate .env.example templates for Next.js, Django, Laravel, Rails, and more.
XML Formatter
Format, validate, and minify XML documents. Powered by xml-formatter for robust processing.
HTML to React JSX
Transform raw HTML snippets into valid React JSX/TSX components. Auto-converts class to className and style objects.