Skip to content

Minify JavaScript

Terser, the minifier most build tools use, running inside this page. Modern syntax and modules are understood, and your source is never uploaded.

  • Processed on your device
  • No upload, no waiting
  • No signup, no watermark

The minified JavaScript appears here.

How it works

1

Paste your JavaScript

Or drop the file in. Modules, classes and modern syntax are all understood.

2

Choose the options

Rename local variables, drop console calls, keep licence comments — each is a switch.

3

Copy or download

With the before and after size.

Frequently asked questions

Is my code uploaded?

No, and for source code that is the point. Nothing is uploaded and no request leaves your device. Pasting proprietary source into an online minifier that posts it to a server is a disclosure, whatever the site says about retention — and it is exactly the sort of thing that is done in a hurry without thinking.

Is this the same as the minifier in my build tool?

Almost certainly, yes. This is terser, which is what webpack, Rollup, Vite and most other bundlers use to minify. The difference is only that it runs here, in your browser, rather than on your machine or a server.

Will it change what my code does?

It should not, and that is checked rather than assumed: our tests minify a module, import both the original and the minified version, run them, and compare the results. What DOES change: local variable names (unless you turn that off), constant expressions that can be worked out in advance, and dead code. Anything depending on a function's name at runtime, or on Function.prototype.toString, can break under mangling — turn mangling off if you rely on either.

What does "Module" mean?

Whether your code is parsed as an ES module or as a plain script. Modules can use import and export and are always in strict mode. It is on by default because that is what most modern code is; if your file is an old-style script that uses "with" or relies on non-strict behaviour, turn it off.

Should I drop console calls?

For production, usually yes — they are noise, and they can leak internal detail to anyone who opens the developer tools. It is off by default because silently deleting code is not something a tool should do without being asked.

Does it keep licence comments?

Yes, by default. Comments beginning /*! and comments containing @license or @preserve are kept, because stripping them from someone else's MIT-licensed library is a licence violation. Ordinary comments are removed.

Can it produce a source map?

Not on this page. A source map is only useful next to the original file at a known URL, which does not fit a paste-and-copy tool — your build tool is the right place for that.

Which library is it?

terser 5.51.2, BSD-2-Clause licensed, served from this site rather than a CDN and downloaded only when you open this page.