simpletool.io

JavaScript Minifier

Compress JavaScript safely with Terser.

Terser runs in your browser — source never uploads.

Input JavaScript

308 bytes · 12 lines

Minified JavaScript

0 bytes

What is a JavaScript Minifier?

A JavaScript minifier shrinks source code by stripping whitespace and comments, shortening variable and function names (called mangling), replacing constant expressions with their computed values, and applying safe code transformations that the engine would have done anyway at parse time. The result behaves exactly like the original but ships in 30–70% fewer bytes. On top of gzip, minified JavaScript typically transfers in roughly a third of the original source size.

Terser is the modern standard. It forked from UglifyJS when UglifyJS stopped handling modern JavaScript syntax, and has been the default JavaScript minifier in webpack, Rollup, Vite, esbuild (alongside esbuild's own), Next.js, and nearly every modern JavaScript build pipeline for the last five years. We run Terser entirely in your browser via its official browser bundle.

Mangling is the largest single win. Function arguments and local variables get renamed to single letters (namea, greeting b), which drops dozens of bytes per function. Top-level identifiers are preserved unless you tell the minifier they're safe to rename, because third-party code might reach in and expect them by name. Toggle mangling off to keep the minified output readable for debugging.

Drop console removes every console.log, console.debug,console.warn, and console.info call from the output. Useful when you've left debugging logs in the source and want them gone in production. It keepsconsole.error by default since those are usually intentional.

ECMAScript target controls how modern the output is. ES2015 (aka ES6) is conservative — works in every browser from the last decade but misses space savings from modern syntax. ES2020 enables optional chaining (?.) and nullish coalescing (??) which save bytes when they appear. ES2022 is the most aggressive — works in every evergreen browser but not in older embedded runtimes. Pick the highest your deployment tolerates.

Privacy is total: your source never uploads. Paste proprietary code, internal tooling, or NDA-bound snippets without worrying.

How to minify JavaScript

  1. Paste your JavaScript into the input panel.
  2. Set options — toggle mangle, drop-console, and ECMAScript target.
  3. Review output — the size-saved percentage appears underneath.
  4. Copy or download as .js for deploy.

Features

  • Full Terser minification with name mangling.
  • Optional drop-console for production cleanup.
  • ECMAScript target selection (ES2015 / ES2020 / ES2022).
  • Syntax-error feedback with line number.
  • Copy or download output.
  • Runs in your browser — source never uploads.

Frequently asked questions

What does mangling do?
Renames local variables and function parameters to short names like a, b, c. Can shrink output 10–30% on verbose code. Top-level names are preserved by default to keep the module's public API intact.
Why does my output throw a reference error?
Terser can sometimes mangle globals if it doesn't know they're referenced from outside the module. Disable mangling or declare the names as 'reserved' in Terser options. For library code, always mangle with care.
Should I drop console calls in production?
Usually yes — console output shows in dev tools and can leak sensitive info. Dropping them also saves a few bytes. Keep console.error if you have real error reporting you want in prod.
Which ECMAScript target should I pick?
ES2022 if your users are on evergreen browsers (Chrome/Firefox/Safari/Edge updated in the last 2 years). ES2020 is a safe default for slightly older support. ES2015 if you need to run on older embedded runtimes (react-native, node <14).
Does minification affect sourcemaps?
Production builds usually generate sourcemaps alongside minified output so you can debug. This tool doesn't produce sourcemaps — if you need them, run Terser in your build pipeline (webpack, Rollup, esbuild).