Send feedback

Coming from the page: JavaScript Minifier

One moment…

Terser engineModern JS supportNothing uploaded

JavaScript Minifier

Shrink your JS files so they load faster, while they work exactly the same.

Everything runs in your browser: your code and files are never uploaded.

How to minify JavaScript

1

Paste the code

Paste your JavaScript or open a .js file, or try “Example”.

2

Pick the options

Shortening variable names is on; you can keep function names if your code relies on them.

3

Copy or download

Press “Minify” to see the savings, then copy or download the .min.js file.

Options

OptionWhat it doesWhen to change it
Shorten variable namestotalPrice → tTurn it off if you want to read the output.
Keep function and class namesKeeps fn.name and class.nameIf your code or a library relies on function names.
Keep licence commentsKeeps /*! ... */ and @licenseLeave it on for open-source libraries.

Tips

Globals are not renamed. Top-level variables keep their names, because other scripts on the page may use them. In modules (import/export) everything is renamed.

A syntax error? You get the line, column and reason, and a button that takes you there.

Add gzip too. Minified code plus gzip or Brotli on the server gives the smallest download.

Limits worth knowing: Terser assumes your code doesn’t rely on errors that have no other effect, such as reading a let variable before its declaration in a statement that does nothing else; such a statement may be removed. Function names change unless you keep them. Your code stays in your browser.

FAQ

Will my code still work after minifying?

Yes, for valid code. We tested 13 well-known libraries including jQuery, Lodash, D3, Vue and Moment, plus test programs with Arabic text, ran each before and after minifying and compared the results: they matched.

Which engine does it use?

Terser 5.51 (BSD licence), the engine used by popular build tools such as webpack and Vite.

How much does JavaScript minification save?

Usually 50% to 70%. For example jQuery goes from 279 KB to 85 KB and Lodash from 531 KB to 69 KB.

Does it support import, export, classes and ?.?

Yes, all modern JavaScript. If the code has import or export, it is treated as an ES module automatically.

Can minified code be turned back into the original?

You can make it readable with our JavaScript Formatter, but shortened names and removed comments don’t come back. Always keep your original file.