JavaScript Minifier
Minify and compress JavaScript with Terser: safely remove comments and whitespace, optionally shorten variable names, and see the exact bytes saved — all in your browser.
ToolsSoup's JavaScript Minifier is a free online tool that compresses your code to the smallest possible size right in your browser. It is powered by Terser, the same battle-tested minifier used by webpack and modern build tools, so it truly parses your JavaScript instead of blindly stripping characters — template literals, regular expressions, and strings stay intact. It removes comments and whitespace, can shorten local variable names, and shows exactly how many bytes you saved. Nothing is uploaded, so even private scripts stay on your own device.
What is a JavaScript minifier?
A JavaScript minifier compresses source code by removing everything an engine does not need to run it: indentation, blank lines, comments, and unnecessary punctuation. A good minifier does this by actually parsing the code into a syntax tree, so it never breaks on tricky cases like regular-expression literals, template strings with ${} interpolation, or automatic semicolon insertion. The result is JavaScript that behaves identically to the original but downloads and parses faster because it is far smaller.
How to minify JavaScript online
Compressing JavaScript with ToolsSoup takes just a couple of clicks:
- Paste your JavaScript into the input box on the left.
- Choose whether to shorten variable names and whether to keep important comments.
- Click Minify to parse your code with Terser and strip everything that is safe to remove.
- Check the savings summary to see the original size, minified size, and how many bytes you saved.
- Copy the compact result with one click and drop it straight into your page or build output.
Why use a real parser instead of a regex stripper?
JavaScript is deceptively hard to minify with simple find-and-replace rules. A slash can mean division or start a regular expression, comments can appear inside strings, and missing semicolons are inserted automatically by the engine. A naive whitespace stripper silently corrupts code in all of these cases. This tool uses Terser, which builds a full abstract syntax tree, so it understands your code and only removes what is genuinely safe. If your input has a syntax error, it tells you instead of producing broken output.
Why minify JavaScript?
Smaller JavaScript downloads faster and parses sooner, which improves page-load time and Core Web Vitals and lowers bandwidth for you and your visitors. Stripping comments before deploying keeps internal notes out of production, and shortening variable names squeezes out extra bytes. Minified JavaScript is also handy to inline inside a script tag, a bookmarklet, or a generated file where readability does not matter.
Why use this JavaScript minifier?
- 100% free with no ads, sign-up, or usage limits.
- Powered by Terser — the same minifier trusted by modern build tools.
- Runs entirely in your browser — your code is never uploaded to a server.
- Truly parses your JavaScript, so regexes, template literals, and strings stay intact.
- Optionally shortens local variable names for maximum compression.
- Reports a clear syntax error instead of producing broken output.
- Shows byte savings so you can see how much smaller the file got.
- Works offline once the page has loaded.
Frequently asked questions
Is this JavaScript minifier free?
Yes. Every tool on ToolsSoup is completely free to use, with no account, sign-up, or hidden limits.
Is my code safe?
Absolutely. All minifying happens locally in your browser using Terser compiled to JavaScript, so your code is never sent to or stored on any server.
Will minifying break my JavaScript?
No. Because the tool parses your code with Terser instead of stripping characters with regular expressions, it understands tricky cases like regexes, template literals, and automatic semicolon insertion, and only removes what is safe.
What does shortening variable names do?
When enabled, the minifier renames local variables and function parameters to short names like a, b, and c. This saves extra bytes and is safe because the new names are still unique within their scope. Names that are part of your public API are left alone.
Can I keep some comments?
Yes. Turn on Keep important comments to preserve license and other bang or @preserve comments while still stripping the rest. Leave it off to remove every comment for the smallest possible output.
What happens if my JavaScript has a syntax error?
The tool shows a friendly error message describing the problem instead of producing corrupted output, so you can fix the code and try again.