JavaScript Minifier

Compress JS with Terser — mangle & dead-code removal.

Minify JavaScript online with Terser, the maintained UglifyJS successor: rename variables, fold constants, remove dead code and strip comments through a real parser — safely handling regex literals, template strings and ASI. Runs fully in your browser — nothing is uploaded.

How to use JavaScript Minifier

  1. Paste your JavaScript

    Paste your code or upload a .js file into this free online JavaScript minifier to compress it instantly with Terser in your browser, with nothing uploaded.

  2. Enable compress

    Keep Compress on so Terser removes dead code, folds constants and drops unused variables, rewriting the JS logic to be dramatically smaller.

  3. Mangle names

    Leave Mangle on to rename local variables to single letters, or turn it off when you need readable names for debugging while still saving size.

  4. Set module and comments

    Switch on ES module for import/export code, and Keep comments to preserve licence banners while the JavaScript is minified through a real parser.

  5. Minify instantly

    The minified JavaScript appears instantly, and any genuine syntax error is reported with its line and column instead of producing broken output.

  6. Copy or download

    Copy the minified JavaScript to your clipboard with one click or download it as a ready-to-ship .js file straight from your browser.

Frequently asked questions

Is this minifier safe — could it break my code?

It uses Terser, the same battle-tested compressor used by Vite, webpack and Rollup, which parses your code into an abstract syntax tree before transforming it. That's why it safely handles tricky cases (regex literals, template strings, ASI) that regex-based minifiers break. If your code has a syntax error, you'll see a precise message rather than corrupted output.

What is the difference between Compress and Mangle?

Compress rewrites the logic to be smaller — removing dead code, folding constant expressions, collapsing variables. Mangle renames local identifiers to short names like a, b, c. Compress shrinks structure; mangle shrinks names. Using both gives the smallest result; you can disable mangle to keep names readable.

When should I enable “ES module”?

Turn it on if your code uses import/export or should run in strict mode as an ES module. It lets Terser apply module-only optimisations and treat top-level names as safe to mangle. Leave it off for classic scripts that run in the global scope.

Does it work with modern syntax like async/await and optional chaining?

Yes. Terser understands modern ECMAScript including async/await, arrow functions, classes, optional chaining (?.) and nullish coalescing (??). It minifies them without transpiling them down — the output keeps the same language level as your input.

Is my code sent anywhere?

No. Terser runs entirely in your browser via JavaScript — nothing you paste is uploaded, logged or stored.

How do I minify a JavaScript file online for free?

Paste your code or upload a .js file and this free online JavaScript minifier compresses it instantly with Terser, then lets you copy or download the minified .js. Everything runs in your browser, so there's no upload, no sign-up and no file-size limit.

How much smaller does minifying JavaScript make my file?

It depends on your code, but with Compress and Mangle enabled, minified JavaScript is typically 40–70% smaller, and far smaller still once your server gzips it. Removing whitespace, comments, dead code and long variable names is what speeds up page loads.

Related tools — Minifiers