Developer 🔒 Runs in your browser — no data sent to servers

JavaScript Minifier

Make a script as small as possible with Terser, the same minifier webpack uses, without sending it anywhere.

Input
Output

Minify JavaScript Online

A minified script downloads and parses faster. This page is the Code Formatter set to JavaScript minification. It uses Terser, which is loaded into the page the first time you minify, so your code is processed on your own machine.

What Terser does

  • Removes whitespace and comments that the engine does not need.
  • Shortens local names: function add(first, second) becomes function add(d,n).
  • Simplifies code where the result is guaranteed to be the same, such as removing unreachable branches.
  • Stops on syntax errors and reports the line and column, instead of producing broken output.

A small example

A six-line function with a comment, function add(first, second) { return first + second; } followed by console.log(add(1, 2));, comes out as function add(d,n){return d+n}console.log(add(1,2));: the comment and the whitespace are gone, and the two parameters have one-letter names, because nothing outside the function can see them.

Things to keep in mind

  • Keep the original: minified code is for shipping, not for editing.
  • Licence comments that start with /*! or contain @license are kept; all other comments are removed.
  • For whole applications, minify in your build pipeline so it happens on every release.

Related tools

To read minified code, use the JavaScript beautifier. For stylesheets, use the CSS minifier.