JavaScript minifier

Compress JavaScript with Terser.

JavaScript minifier

Mode

0 lines · 0 characters

0 lines · 0 characters

Results update as you type.

Runs in your browser. Nothing uploaded.

How to minify JavaScript

  1. Paste your code into JavaScript.
  2. The minified code appears on the right. The status line shows the size before and after, or the line and column of a syntax error.
  3. Copy it or download it as script.min.js.

What Terser does

Minifying the example shows each step:

  • It removes comments and whitespace, so the comment line and all indentation disappear.
  • It mangles local names: callback, delay and timer become e, t and n.
  • Compression joins two statements in a row with a comma and swaps single quotes for double quotes where it doesn’t cost anything.
  • Modern syntax stays as it is: arrow functions, default parameters, async functions, optional chaining and import and export statements.

Minified is not protected

Minified code is harder to read but not secret. Anyone can paste it into the JavaScript formatter and get indented, readable code back, just with short variable names. Never put API keys, passwords or anything private in code that runs in the browser.