Quick answer: minification removes what browsers don't need — comments, whitespace, and (with mangling) long variable names — without changing what the code does. Percent saved = (input − output) ÷ input × 100. On our 823-byte cart-totals sample, Terser strips it to 651 B (20.9% saved), compresses to 598 B (27.3%), and compress+mangle reaches 390 B (52.6% saved, 277 B gzipped). All three passes compute the identical $74.68 cart total. Everything runs locally; no code is uploaded.

Your JavaScript

Ad
Input
Output
Saved
Gzip in → out
Ad

What Each Terser Pass Buys You

PassWhat it removes823-B sample →Saved
Strip onlyComments, indentation, newlines651 B172 B (20.9%)
Compress…plus dead branches, constant folding, joined declarations598 B225 B (27.3%)
Compress + mangle…plus 1–2 character names, inline helpers (TAX_RATEt)390 B433 B (52.6%)
Same file, gzippedTransport compression on top of the smallest pass277 B29.5% off the 393-B gzip

Every row was measured with Terser 5.51.2 — the exact browser bundle this page loads — on the sample behind the Sample button. Your mileage depends on your comment density and name lengths: a heavily commented file shrinks more; a machine-generated bundle shrinks less.

How the JS Minifier Works

This tool is a thin, honest wrapper around Terser 5.51.2 (BSD-2-Clause), the minifier that webpack, Vite, and Parcel lean on in production builds. It loads the official Terser browser bundle on first use and runs it in your tab. No server sees your code, which makes it usable for quick one-off shrinks, snippets heading into CMS blocks, or checking what a bundler pass would buy you.

The math

Bytes saved = input − output. Savings percent = (input − output) ÷ input × 100. The tool counts UTF-8 bytes (not characters) so multi-byte strings report honestly, and when your browser supports CompressionStream it also shows gzip sizes for both sides — the number that actually crosses the network.

How to use it

Paste code (or hit Sample), pick a preset, and results update as you type. Strip only is the safe default for code you'll still need to debug from stack traces: line breaks go but nothing is renamed. Compress rewrites the logic to shorter equivalents. Compress + mangle also renames top-level names — smallest output, but other scripts can no longer call your globals by name, and Function.prototype.name changes.

A worked example

The Sample button loads an 823-byte cart-totals script: a tax constant, a money formatter, a per-line discount helper, and a cartTotal() that returns subtotal, tax, and total. Run each preset and the output column walks down 651 → 598 → 390 bytes. We verified all three outputs in Node against the same bundle: each one computes {subtotal: "$68.99", tax: "$5.69", total: "$74.68", itemCount: 2} from a two-item cart — identical answers, 52.6% of the bytes gone at the strongest pass, and 277 B once gzipped.

One caution worth repeating: minification is not obfuscation. Anyone can pretty-print 390 bytes back to readable form in seconds. If the goal is deterring reverse engineering rather than shipping smaller files, that's a different tool — our JS Obfuscator lane covers it.

Frequently Asked Questions

What does minifying JavaScript remove?

A minifier like Terser removes comments and whitespace, shortens local variable names, folds constants, drops unreachable code, and applies safe syntax transforms. The output is functionally identical JavaScript that parses to the same behavior. Unsafe assumptions, like relying on Function.prototype.toString, can break, so test after minifying.

How much smaller is minified JavaScript?

Hand-written JS typically shrinks 30–50% raw, and applying gzip on top commonly cuts 70–80% from the original size. Variable-name mangling contributes most of the raw savings in large files. For production sites this directly improves time-to-interactive on slower connections.

Is Terser still the right choice for ES6+ code?

Yes — Terser was forked specifically to handle modern ECMAScript syntax that the older UglifyJS could not parse. It fully supports ES6 through current syntax like optional chaining and nullish coalescing. Running it in your browser means no Node install is needed for quick one-file minification.