Compress JavaScript with Terser — the minifier behind most modern bundlers — right in your browser.
Input · drop a file
Output
How a minifier shrinks code, pass by pass
Minifiers don’t zip your file — they rewrite it into the smallest code that behaves identically. Step through what a JavaScript minifier like Terser does to one small function. CSS and HTML minifiers follow the same idea with their own rules.
/* Total price of a ticket */
function ticketTotal(garments) {
let total = 0;
for (const garment of garments) {
total = total + garment.price;
}
return total;
}
Readable source with a comment, indentation and descriptive names.
172 bytes · 0% smaller than the original
What Terser does
Compress: removes dead code, folds constants, turns if into && or ternaries, and true into !0.
Mangle: renames local variables and parameters to one or two letters. Global names and object properties are not renamed, so your public API keeps working.
Removes comments and whitespace.
Turn off Mangle names when you need readable stack traces and have no source maps.
Questions
How much smaller will my JavaScript be?
Commonly 30–60% before gzip, depending on comments and name lengths.
Does it transpile to older browsers?
No. Minifying keeps your syntax level; use a compiler such as Babel or esbuild to target older browsers.