Tool Logo

JavaScript Minifier

Make JavaScript smaller without changing what it does.

0 characters

Loading tool…

How to use the javascript minifier

The minifier uses Terser, the minifier behind most JavaScript build tools. It parses your code, removes whitespace and comments, simplifies expressions and can shorten local variable names, then prints the smallest equivalent program. Because it works on the parsed code rather than on text, strings, URLs and regular expressions are never damaged. Licence comments (/*! ... */ and @license) are kept.

  1. Paste your JavaScript or upload a .js file.
  2. Choose whether to shorten variable names, and whether the code is an ES module.
  3. Check the size saving and copy the minified code.

When to use it

  • Small sites

    Minify a script without setting up a build tool.

  • Bookmarklets and snippets

    Get code small enough to embed or share.

  • Checking savings

    See how much a script would shrink before adding minification to a build.

Frequently asked questions

Will the minified code work the same?

Yes. Terser only applies transformations that keep the program's behaviour, so the output does the same as the input.

What does "shorten variable names" do?

It renames local variables and function parameters to short names like a and b. Global names and object properties stay as they are, so other code can still use them.

When should I choose ES module?

If your file uses import or export. Module code is parsed in strict mode and top-level names can be shortened too.

Are licence comments kept?

Yes. Comments starting with /*! or containing @license or @preserve are kept; all other comments are removed.

Is my code uploaded?

No. Everything runs in your browser; nothing you paste or upload is sent to our servers.