Skip to content
Tooletto

JS Minifier

Minify JavaScript using Terser — the same engine major build tools rely on. Strips whitespace and comments, and optionally mangles variable names, to produce smaller, still-valid output entirely in your browser.

  • Files never leave your device
  • Free, no signup
  • No watermarks
  • Works offline once loaded
Loading tool…

How to js minifier

  1. 1

    Paste your code

    Drop in any valid JavaScript file or snippet.

  2. 2

    Choose your options

    Keep variable mangling on for the smallest output, or turn it off if you need to read the result.

  3. 3

    Copy the result

    Copy the minified code, along with the size saved.

What minification actually does under the hood

Removing whitespace and comments is the easy, obvious part of minification — and on its own it barely moves the needle on well-written code. The real size reduction comes from two deeper transformations: mangling, which renames every local variable and function argument to the shortest possible identifier (`accumulator` becomes `a`, `temporaryResult` becomes `t`), and dead-code elimination, which removes branches and expressions that a static analysis of the code can prove will never execute or never affect output. Both require actually understanding the code's structure — its scopes, which names are local versus exported, which branches are provably unreachable — which is why a real parser-based tool like Terser produces meaningfully smaller output than a naive find-and-replace over whitespace ever could.

Why most developers rarely touch a standalone minifier anymore

Bundlers like Webpack, esbuild, Rollup and Vite minify their output automatically as part of a production build, almost always using Terser or a Terser-compatible engine under the hood — so for anyone working inside a modern JavaScript project, minification already happens invisibly every time they run a build command. A standalone tool like this one covers the cases that fall outside that pipeline: a single script tag with no build step, a quick check of how much a snippet would shrink, or a one-off file that needs compressing without pulling in an entire bundler configuration just for that purpose.

The inverse of formatting, not a replacement for it

Minifying and formatting are opposite operations on the same code: this tool strips out the whitespace, structure and readability that a formatter like Prettier deliberately adds back in. Its sibling tool, the JavaScript Formatter, undoes exactly what this one does — useful for the reverse direction, taking a minified file someone handed you and turning it back into something readable enough to actually debug.

A real build pipeline normally pairs minification with a source map — a separate file that maps every position in the minified output back to its original line in the source — specifically so a debugger can still show readable code and correct line numbers in production, despite the file actually running being unreadable. This standalone tool intentionally does not generate one, since it is meant for a quick one-off shrink rather than a production deployment; anything going into a real build pipeline should go through a bundler that emits a matching source map alongside it.

Frequently asked questions

Is my code sent to a server?

No. Terser is downloaded to your browser and runs there — minification happens entirely on your device. Proprietary or internal code never leaves your machine, which is not true of every online minifier.

Can minification break my code?

Not when done correctly — Terser parses your code into a real syntax tree rather than pattern-matching text, so the transformed output behaves identically to the original for the vast majority of code. The one genuine edge case: code that inspects its own source at runtime, for example calling `Function.prototype.toString()` on a function and parsing the result, or relying on a variable or function name as a string (some dependency-injection patterns do this). Mangling renames things, so introspection like that can see different names post-minification. It is rare, but worth knowing about if your code does anything unusual with reflection.

Is the minified output still valid, runnable JavaScript?

Yes. The output is ordinary JavaScript — just shorter. You can drop it straight into a `<script>` tag or a build output exactly as you would the original file.

When should I actually use this?

For production bundles, a script embedded somewhere size-constrained (a browser extension, a tracking snippet, a size-limited widget), or a one-off file you need shrunk quickly without wiring up a build step. You would not minify your source or development files — keep those readable, and minify only the final build output, the same way a bundler would.

Why does the output look unreadable?

That is the point. Whitespace, comments and long variable names exist for humans reading the source, not for the JavaScript engine executing it. Stripping them (and shortening names, if mangling is enabled) reduces the number of bytes sent over the network without changing what the code does.