JavaScript Minifier

Minify JavaScript with terser, the same minifier used by Vite, webpack and Rollup, without leaving your browser.

JavaScript
Minified JavaScript
Runs locally in your browser

About the JavaScript Minifier

This tool runs terser locally. It removes whitespace and comments, renames local variables and function parameters to single letters, folds constant expressions, drops unreachable code, and applies dozens of smaller transformations that preserve behaviour. Two compression passes are used, which finds a few more savings on typical code. Savings of 40 to 60 percent before gzip are normal for hand-written scripts.

Renaming is safe for locals but never touches globals or property names, since those may be referenced elsewhere. Tick the ES module option for code with import and export so top-level names are handled correctly. Licence comments beginning with /*! can be kept for compliance.

A syntax error stops minification with the line and column, which makes the tool a fast validator as well. Because terser is a large library, it loads on demand when you first minify. To make minified code readable again, use the JavaScript Formatter; names cannot be restored, but the structure can.

How to use

  1. Paste the JavaScript or upload a file.
  2. Untick "Rename local variables" if you need readable stack traces, and tick "ES module" for import/export code.
  3. Copy or download the minified output; the stats line shows the saving.

Common questions

Is minified code still debuggable?
Stack traces will show renamed variables and a single line. Keep an unminified copy, or untick renaming for a middle ground.
Does it transpile modern syntax to ES5?
No. terser outputs the same language level it reads; ES2020 in gives ES2020 out. Transpiling is a separate step.
Why did minification fail on JSX or TypeScript?
terser reads plain JavaScript. Compile TypeScript and JSX first.
Can it remove console.log calls?
Not with the current options; that is a build-config choice best made per project.