JavaScript Minifier

Minify JavaScript with Terser: compress, mangle names and strip comments.

What does a JavaScript minifier do?

A JavaScript minifier makes scripts smaller by removing whitespace and comments, shortening local variable names (mangling) and simplifying code (compression), so pages download and run faster.

Options

  • Compress — removes dead code and simplifies expressions.
  • Mangle — renames local variables and functions to short names.
  • Keep license comments — keeps /*! ... */ and @license comments.
  • ES module — enable for code that uses import/export.

The tool runs Terser, the minifier used by webpack, Vite and Rollup. Syntax errors are reported with the line and column.

Good to know

Mangling never renames global variables or object properties, so the public API of your script stays the same. Always test minified code before deploying.

Frequently asked questions

Is minified JavaScript faster?

It downloads faster and parses slightly faster. Combined with gzip or Brotli the savings are largest.

Why do I get a syntax error?

The code is not valid JavaScript (or uses import/export without the ES module option).

Is my code uploaded?

No, Terser runs in your browser.