JavaScript Minifier

Compress JavaScript with real Terser mangling and dead-code removal, or beautify minified code back to readable form. Everything runs in your browser.

Input
0 B
Output
0 B
Saved
0%

Real minification, not just whitespace

Stripping spaces and newlines is the easy part. This tool runs your code through Terser, a proper JavaScript compressor, so it also shortens local variable names, folds constants, and removes unreachable branches. The result is meaningfully smaller than a whitespace-only pass, which is why the exact byte count and percentage saved appear above every time.

The options explained

  • Mangle names renames local variables and parameters to single letters. This is where most of the size saving comes from. Turn it off to keep your original names.
  • Keep function names preserves the names of functions even while mangling everything else, which matters if your code relies on fn.name or shows function names in stack traces.
  • Remove console statements deletes console calls so debug logging never ships to production.
  • Mangle top-level names treats module-level names as private and can drop anything unused. Only enable it for self-contained files, never for a script that exposes globals.

A note on secrets and source maps

Nothing you paste here leaves your browser, so private code is safe. Even so, make it a rule never to paste live API keys, passwords or tokens into any online tool. This tool does not generate a source map; if you need to debug minified code, produce maps in your build step instead. To restore a compressed file to a readable state, switch to Beautify, which re-indents it with the spacing you choose.

Working across formats? Pair this with the HTML formatter, the CSS minifier or the JSON formatter.

Frequently asked questions

What does minifying JavaScript actually do?
It removes everything the engine does not need to run your code: comments, whitespace and line breaks, and it can shorten local variable names (mangling). The behaviour is identical, the file is just smaller and faster to download. This tool uses Terser, the same compressor behind most production build pipelines.
What is name mangling?
Mangling renames local variables and function parameters to single letters, so a name like userCount might become n. It only touches names that are safe to rename inside their scope, never global identifiers or property names, unless you enable the toplevel option. Turning mangling off keeps your original names but produces a larger file.
Is my code uploaded anywhere?
No. Everything runs in your browser with JavaScript, so nothing you paste is ever sent to a server. It is safe to minify private or unreleased code here. As a general habit, though, never paste production secrets, API keys or tokens into any online tool.
Does this generate a source map?
No. This tool returns minified code only, with no source map. If you need to debug minified code in production, generate source maps as part of your build step with Terser, webpack, esbuild or Vite instead.
Why did my function disappear after minifying?
If you enable the toplevel option, Terser treats top-level names as private and will drop any that are never used, since nothing outside the file could reference them. Leave toplevel off if your script exposes functions to other scripts or inline handlers.