What does a JavaScript minifier do?
Minifying JavaScript is more than removing spaces. A good minifier understands the code: it parses it into a syntax tree, simplifies it and writes it back as compactly as possible. The result does exactly the same thing but weighs much less, which means faster downloads and less for the browser to parse.
This tool uses Terser, the minifier behind most modern bundlers, and supports ES2015+ syntax such as arrow functions, classes, modules, async/await and optional chaining. You control the main steps. Compress removes dead code (branches that can never run, unused functions) and simplifies expressions. Mangle renames local variables and function parameters to one or two letters. Keep license comments preserves comments starting with /*! or containing @license. Drop console removes console.* calls left over from debugging.
Mangling never touches global names or object properties, so code that other scripts call keeps working. JSX and TypeScript are not supported: compile them to plain JavaScript first. If the code has a syntax error, you get the parser message pointing to the problem. The size before and after and the percentage saved appear after each run.
A good rule of thumb is to keep the readable source in your project and minify only the copy you publish, so you can always come back to the original when you need to change something. The code is minified in your browser and never uploaded. You get one free try per tool: one file or one pasted text. After that you can still re-process the same text with different options, but new input needs ToolStudio Pro, which gives unlimited use of every tool, several files at once downloaded together in a ZIP, and no ads. You can cancel anytime.
How to minify JavaScript
- Paste your code or drop a .js, .mjs or .cjs file.
- Choose the options: compress, mangle, keep license comments, drop console.
- Run the minifier; if there is a syntax error, fix it using the message shown.
- Check the bytes saved and copy or download the minified script.
When to minify JavaScript
- Scripts for static sites or WordPress themes without a bundler.
- Bookmarklets, which need to be as short as possible.
- Tracking snippets and widgets embedded in other sites.
- Removing console.log calls before shipping a quick script.
- Measuring how much a file could shrink before setting up a build.
Compress vs mangle
Compress changes the logic into a shorter equivalent: if (true) { a() } becomes a(), unused variables disappear and constant expressions are folded. Mangle only renames: function total(price, quantity) { return price * quantity } becomes function total(n,t){return n*t}. Each saves bytes on its own and together they give the biggest reduction.
Minified is not obfuscated
Minification makes code hard to read, but not secret. Anyone can re-indent it with a formatter; what they cannot recover are the original local variable names. Never put API keys or secrets in client-side JavaScript, minified or not.
Frequently Asked Questions
Does it support modern JavaScript?
Yes, Terser handles ES2015 and later: classes, modules, arrow functions, async/await, optional chaining and more.
Can I minify TypeScript or JSX?
No. Compile them to plain JavaScript first, then minify the output.
Will mangling break my code?
Mangle renames local variables and parameters only, not globals or object properties, so code that is called from outside keeps working.
Can I undo a minification?
You can re-indent it with the JavaScript formatter, but mangled variable names cannot be restored. Keep your original source.
Is my code uploaded?
No. Terser runs in your browser; the code never leaves your device.
Is it free?
You can minify one file or one pasted text for free and re-run it with other options. New input needs ToolStudio Pro, which gives unlimited use, several files at once in a ZIP and no ads.