ToolJutsu
All tools
Developer Tools

JavaScript Minifier

Minify JavaScript to reduce file size.

Compress removes dead code and simplifies expressions. Mangle shortens local variable and function names.

0 B
Tip: press Ctrl/ + Enter
Processed on your device. We never see your files.

How to use JavaScript Minifier

What this tool does

A JavaScript minifier takes readable source code and rewrites it into the smallest equivalent form. This tool uses Terser, the same minifier that powers most modern build pipelines, running entirely inside your browser. It does two kinds of work, each controlled by a toggle. Compress transforms the code: it removes dead code, drops unused declarations, folds constant expressions, and collapses statements. Mangle renames local variables and parameters to single letters. Together they typically cut a hand-written file to a fraction of its original size, and the tool shows you the before and after byte counts so you can see exactly how much you saved.

Why you might need it

JavaScript is expensive for a web page: the browser has to download it, parse it, and execute it before the page becomes interactive. Smaller scripts download faster and parse faster. Source code is written for humans — full of descriptive names, comments and whitespace — and none of that helps the machine. Minifying strips it all away. You might reach for this tool when you need a quick minified build without setting up a full toolchain, when you want to inline a script into an HTML page, when you are shipping a small widget or snippet, or simply when you want to measure how much a particular file could shrink.

How to use it

  1. Paste your JavaScript into the input box, or drop a .js file onto it.
  2. Choose your options: leave Compress and Mangle on for the smallest output, or turn one off if you need to debug a problem.
  3. Click Minify JavaScript, or press Ctrl/Cmd + Enter. A short “Minifying…” state appears while Terser works.
  4. Read the summary for the size saved, then copy the minified output.

Common pitfalls

Minified code is not meant to be debugged. If something breaks after minification, the fix is almost never to read the output — it is to narrow down the cause. Start by turning Mangle off: most “minification broke my code” problems come from code that depends on a name surviving, such as a framework that inspects a class or function name at runtime, or anything using eval. If the input has a syntax error, Terser refuses to minify it and shows the error; that message points you at the real problem. Finally, remember this tool minifies but does not transpile — if your input uses syntax an old browser cannot run, the minified output will still use it.

Tips and advanced use

Treat minification as a build step, not an editing step: keep your readable source in version control and minify a copy. Watching the saved percentage is informative — if a file you believed was production-ready still shrinks substantially, it was not being minified properly. Combine minification with server-side gzip or Brotli compression; they work at different layers and the savings stack. When you only need a modest size reduction without renaming anything — for example because you want the output to stay somewhat legible — minify with Compress on and Mangle off. And because every step runs locally, it is safe to minify private or proprietary code here; none of it ever leaves your device.

Frequently asked questions

Is my JavaScript sent to a server to be minified?
No. The minifier runs Terser directly in your browser tab, so your code is processed on your own device. Nothing is uploaded — you can confirm this in the browser's Network tab while you minify.
What is the difference between compress and mangle?
Compress rewrites the code to be smaller and faster: it removes unreachable code, drops unused variables, and simplifies expressions. Mangle renames local variables and function parameters to short names like a or b. They are independent — you can use either, both, or neither.
Why did minifying break my code?
The most common cause is relying on a function's name or a variable name at runtime, which mangling changes. Code that uses Function.prototype.name, eval, or with can behave differently after mangling. If output misbehaves, try minifying with mangle turned off.
Can I minify modern JavaScript?
Yes. Terser understands modern syntax including arrow functions, classes, async/await, template literals and optional chaining. It minifies that syntax but does not transpile it down to older JavaScript — the output targets the same language level as the input.
Why does it report a syntax error?
Terser must fully parse your code before it can minify it. If the input has a syntax error — a missing brace, an unclosed string, an unexpected token — minification stops and the error message is shown so you can fix it.

Related tools