JavaScript Minifier
Minify JavaScript to reduce file size.
Compress removes dead code and simplifies expressions. Mangle shortens local variable and function names.
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
- Paste your JavaScript into the input box, or drop a
.jsfile onto it. - Choose your options: leave Compress and Mangle on for the smallest output, or turn one off if you need to debug a problem.
- Click Minify JavaScript, or press Ctrl/Cmd + Enter. A short “Minifying…” state appears while Terser works.
- 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?
What is the difference between compress and mangle?
Why did minifying break my code?
Can I minify modern JavaScript?
Why does it report a syntax error?
Related tools
JavaScript Beautifier
Format and indent minified JavaScript.
HTML Minifier
Minify HTML markup for faster pages.
HTML Beautifier
Format and indent messy HTML.
Cron Expression Builder
Build and explain cron expressions in plain English.
JSONPath Tester
Test JSONPath queries against a JSON document.
Timestamp to Date
Convert Unix timestamps into readable dates.