Skip to content
ToolMug

JavaScript Minifier

Shrink JavaScript for production. Terser removes whitespace and comments, shortens local variable names and simplifies code, and you see exactly how many bytes were saved.

Runs in your browser — nothing you enter is uploaded

How to use

  1. Paste your JavaScript.
  2. Choose whether to shorten variable names and keep license comments.
  3. Click Minify, or press Ctrl+Enter (⌘+Enter on Mac).
  4. Copy or download the minified file.

Options explained

Shorten variable names
Renames local variables and function parameters to single letters. Global names are kept so other scripts can still use them.
Keep license comments
Keeps comments that start with /*! or contain @license or @preserve, which many licenses require you to retain.

Examples

function add(first, second) {
  // sum
  return first + second;
}

minifies to function add(d,n){return d+n}.

Frequently asked questions

Is the minified code safe to use?

Terser only applies transformations that keep the behaviour of valid code. Code that relies on function names at run time (for example via Function.name) can behave differently when names are shortened; turn that option off in that case.

Does it support modern JavaScript?

Yes. Terser understands current syntax including classes, async functions, optional chaining and modules. It does not convert code for older browsers.

Is my code uploaded?

No. Terser runs in your browser.

Privacy

This tool runs entirely in your browser. Your files and text are processed on your device and are never uploaded to our servers.

Related tools