Free JavaScript Minifier
Paste or upload your JavaScript and compress it instantly using Terser. Dead code removal, variable mangling, and whitespace stripping — all in your browser. Nothing uploaded.
What Terser does to your code
Terser isn't just a whitespace remover. It parses your JavaScript into an abstract syntax tree, applies a series of transformations, then serializes the result back to the smallest valid JS that runs identically to your source.
The transformations happen in layers:
Whitespace and comments. Everything the parser ignores — indentation, newlines, // comments, /* blocks */ — goes first. On heavily commented code this alone can cut 15–20%.
Variable mangling. Local variable names get replaced with single characters. isFriendly becomes n. calculateTotalPrice becomes a. Terser tracks every reference before renaming — globals and exports stay untouched.
Dead code elimination. Branches that can never run get removed. An if (false) { ... } block disappears entirely. Constants that evaluate to the same value get collapsed.
Constant folding. 60 * 60 * 24 becomes 86400. "hello " + "world" becomes "hello world". The runtime never has to compute them.
The result is typically 30–60% smaller than the source. Combined with gzip on your server, you're usually looking at 70–80% total reduction.
Before and after
Here's what Terser does to a short, readable function:
Before — 128 bytes
function calculateDiscount(price, isMember) {
// Members get 20% off
const discountRate = isMember ? 0.20 : 0;
return price - (price * discountRate);
}After — 67 bytes (48% smaller)
function calculateDiscount(n,i){return n-n*(i?.2:0)}The logic is identical. price becomes n, isMember becomes i, the comment is gone, and 0.20 is shortened to .2.
Online tool vs. a build pipeline
If you're running webpack, Vite, Rollup, or esbuild, Terser is already part of your production build — those bundlers run it automatically. You don't need a separate tool.
Use this when:
- You're working with a file outside your normal build process — a third-party script, a legacy file, a one-off prototype
- You want to check how much a specific file compresses before committing to a build setup
- You have no build pipeline at all
If you're minifying the same files regularly, it's worth adding Terser to your workflow directly:
Terser CLI
npm install terser --save-dev
npx terser input.js -o output.min.js -c -mThe -c flag enables compression, -m enables mangling. That's the same configuration this tool uses.
A note on source maps
Minified code is hard to debug. Variable names like n and i don't mean much in a stack trace. If you're minifying code that might need debugging in production, generate a source map alongside the minified file — it maps compressed line numbers back to your original source.
MinifyTools doesn't generate source maps. For production workflows where debuggability matters, use the Terser CLI or your build tool's source map option. For one-off compression of third-party files you don't need to debug, this tool is fine.
JavaScript Minifier FAQ
What JavaScript minification engine does this use?
MinifyTools uses Terser — the same minifier used by webpack, Vite, Rollup, and Next.js. It supports modern ES2020+ syntax including optional chaining, nullish coalescing, and async/await. UglifyJS doesn't handle ES6+ reliably. Google Closure Compiler was officially deprecated. Terser is the current standard, with over 18 million weekly npm downloads.
Is it safe to minify production JavaScript here?
Yes. Your code runs through Terser entirely in your browser — nothing reaches a server. There's no logging, no storage, no account required. You can verify this in your browser's network tab: no outbound requests are made while you paste or minify.
Will minified JavaScript still work correctly?
Yes. Terser analyses your code's full AST before renaming anything. Variable renaming is consistent — every reference to a variable gets renamed to the same character throughout the file. The output is functionally identical to your source.
What's the difference between minification and obfuscation?
Minification makes code smaller while keeping it logically readable. Variable names get shortened, but the structure stays intact. Obfuscation deliberately makes code hard to understand — using eval, base64 encoding, and intentionally confusing patterns. Minification doesn't protect your code from being read. If you need actual code protection, you need a dedicated obfuscator on top of minification.
Does minification help with Core Web Vitals?
Yes, directly. Smaller JS files download and parse faster. A 60% reduction on a 200KB script saves around 120KB of transfer, which has a measurable effect on Time to Interactive and Total Blocking Time. That said, code splitting and lazy loading usually have a bigger impact on LCP than raw file size alone — minification is one part of a broader performance budget.
How much can JavaScript minification reduce file size?
30–60% on its own. The biggest wins come from code with long variable names, lots of whitespace, and inline comments. A tightly-written, comment-free file might only compress 15–20%. Stack it with gzip on your server and you're typically in the 70–80% range total.