Overview
Introduction
Every unnecessary byte in a shipped JavaScript bundle costs load time, especially on slower connections.
This tool minifies JavaScript using Terser, the same minifier most modern bundlers run by default, entirely in your browser.
What Is JavaScript Minifier?
A minifier that removes whitespace and comments, shortens variable and function names where safe, and applies basic compression transforms.
The output is functionally equivalent to the input; only its size and readability change.
How JavaScript Minifier Works
Terser parses the code into an AST, applies compression and mangling passes, and re-prints the smallest equivalent code.
A syntax error in the input is reported with its line and column instead of producing output.
When To Use JavaScript Minifier
Use it before shipping a standalone script that isn't already going through a bundler's minification step.
It's also useful for quickly estimating how much a piece of code could shrink.
Often used alongside JavaScript Formatter, JavaScript Validator and JavaScript Obfuscator.
Features
Advantages
- Runs entirely client-side.
- Uses Terser, the production-grade minifier trusted by major JS build tools.
- Reports exact byte savings, useful for judging whether minifying a small script is even worth it.
Limitations
- Aggressive mangling can occasionally change behavior in code that relies on `Function.prototype.name` or similar introspection; review minified output before shipping unusual code.
Examples
Best Practices & Notes
Best Practices
- Always keep an unminified source copy; minified output isn't meant to be hand-edited.
- Check the size savings panel to confirm the minification was worthwhile for small scripts.
Developer Notes
Uses Terser's `minify()` with `compress` and `mangle` enabled, dynamically imported so the minifier itself doesn't bloat every other tool's bundle.
JavaScript Minifier Use Cases
- Shrinking a standalone script before embedding it in a page
- Comparing minified vs. unminified size for a code snippet
Common Mistakes
- Editing the minified output directly instead of the original source, making future changes much harder.
- Debugging a production error directly against mangled output; no source map is generated here, so pairing minification with your build tool's source maps keeps stack traces readable.
Tips
- If minification fails, the error points at a syntax problem; run it through the JavaScript Validator first if you're unsure.
- Test minified output in the environments you target before shipping, since mangling and compression can occasionally interact with edge-case syntax.