JavaScript Minifier
Minify JavaScript using Terser, the same minifier most modern bundlers use internally, entirely in your browser.
Tool guide
What this tool does
JavaScript Minifier compresses JavaScript using Terser (the minifier behind most modern bundlers’ production builds), with optional variable-name mangling and logic compression, entirely client-side, showing a before/after size comparison.
Shrinking a JavaScript file for production usually happens automatically inside a bundler’s build step, but minifying a quick standalone script or snippet by hand means either installing tooling or finding an online minifier you can trust with your code.
This tool runs Terser, the actual minifier most modern JavaScript bundlers (Vite, webpack, Rollup) use internally for production builds, entirely in your browser, so your code is never sent anywhere.
How to use JavaScript Minifier
- Paste your JavaScript.
- Toggle mangle (shorten variable names) and compress (optimise logic) as needed.
- Review the before/after size comparison and any error message.
- Copy or download the minified output.
Tips for better results
- Mangling renames local variables and function parameters to short, meaningless names (like a, b, c), which shrinks size but makes error stack traces much harder to read without a source map, consider disabling it for code you’re still actively debugging.
- Terser performs real syntax parsing, not just text manipulation, so invalid JavaScript will produce a parse error here rather than a broken minified result, a useful side benefit for catching syntax mistakes.
- Compress applies safe logic-level optimisations (removing dead code, simplifying expressions) beyond simple whitespace removal, this is what makes Terser’s output meaningfully smaller than a naive minifier.
- Global variables and exported names aren’t mangled by default, since renaming something another file or script depends on by name would break that reference, Terser is conservative about what it’s safe to rename.
Common use cases
- Minifying a standalone script or utility file without setting up a full bundler.
- Checking how much smaller a piece of JavaScript becomes with Terser’s real production-grade minification.
- Validating that a JavaScript snippet has no syntax errors (minification will fail clearly if it does).
- Learning what mangling and compression actually do to real code by comparing before/after output.
Common mistakes to avoid
- Enabling mangling for code you’re still actively debugging, then struggling to read the resulting error stack traces full of single-letter variable names; disable mangling while debugging, re-enable it for the final production output.
- Pasting JavaScript with an actual syntax error and being confused by the resulting error message; Terser performs real parsing, so a genuine syntax mistake in your code will surface here rather than being silently passed through.
- Expecting minification to change your code’s behaviour; a correct minifier (Terser included) preserves identical runtime behaviour, only the file size and variable names change.
Frequently asked questions
Is this the same minifier real build tools use?
Yes, Terser is the actual minifier most modern JavaScript bundlers (Vite, webpack, Rollup) use internally for their production builds, this tool runs the real library, not a simplified imitation.
Why would minification fail with an error?
Terser performs genuine syntax parsing before minifying; if your JavaScript has an actual syntax error, that error will surface here clearly rather than producing a silently broken minified result.
Does mangling make debugging harder?
Yes, it renames local variables to short, meaningless names, which shrinks file size but makes error stack traces much harder to interpret without a source map; disable it while actively debugging.
Is my code uploaded anywhere?
No, minification runs entirely in your browser using the Terser library; your code is never uploaded anywhere.
Feedback & suggestions
Help us improve JavaScript Minifier. We read every message.