Skip to main content
ToolsHub

JavaScript Minifier

Shrink JavaScript with the same Terser engine bundlers use: strip comments and whitespace, compress expressions, and mangle variable names, with a live before-and-after size comparison — all in your browser.

Updated

Files never leave your browser

Minification runs entirely in your browser with Terser — your code is never uploaded.

How to use JavaScript Minifier

A JavaScript minifier shrinks your code by removing everything a browser does not need — comments, whitespace, and redundant syntax — and optionally renaming variables to short names. Smaller JavaScript downloads faster and parses quicker, which directly improves page load time and Core Web Vitals. This tool uses Terser, the same battle-tested engine that bundlers like webpack and Rollup rely on, and runs it entirely in your browser. Paste your code, choose whether to mangle names, and get minified output with a clear before-and-after size comparison. Nothing is uploaded, so even proprietary code stays private.

  1. Paste your JavaScript into the input box.
  2. Decide whether to enable name mangling.
  3. Click Minify JavaScript.
  4. Review the size saved in the stats.
  5. Copy or save the minified output.

Your data never leaves your device — 100% private processing.

Why minified JavaScript matters

Every kilobyte of JavaScript a page ships has to be downloaded, parsed, and compiled before it can run, and on slower devices and networks that work adds up fast. Minification attacks the download and parse cost directly by stripping out the characters that exist purely for human readability. The savings are often dramatic — comment-heavy, well-spaced source can shrink by half or more — and because smaller scripts parse faster, the benefit compounds. Faster JavaScript means a quicker Time to Interactive and better Core Web Vitals, which affect both user experience and search ranking. For production sites this step is essentially mandatory, which is why every major build pipeline runs a minifier automatically.

When to mangle and when not to

Name mangling produces the smallest files, but it makes the output nearly impossible to read, which matters in two situations. First, if you are minifying code you intend to debug or hand-edit afterwards, leave mangling off so the variable names survive. Second, mangling can interfere with code that relies on function or class names at runtime — for example certain dependency-injection frameworks or code that reads Function.name. For ordinary application and library code, mangling is safe and recommended. When in doubt, minify with mangling off first, confirm everything works, then enable it and test again to capture the extra savings.

Worked examples

Plain minify

Inputs: function add(a,b){ return a+b }

Result: function add(a,b){return a+b}

With mangling

Inputs: verbose variable names

Result: Renamed to a, b, c for smaller output

Glossary

Minification
Removing unnecessary characters from code without changing its behaviour.
Mangling
Renaming variables and functions to short names to save bytes.
Terser
A widely used JavaScript minifier and compressor.
Tree shaking
Eliminating unused code; related to but distinct from minification.

Related reading

Frequently Asked Questions

Free · No spam

Get weekly tool tips & updates

New tools, power-user tips, and productivity hacks — delivered free every Friday.

No spam, ever. Unsubscribe with one click.

Why use JavaScript Minifier?

  • Uses Terser, the industry-standard minifier, for reliable output
  • Optional name mangling for the smallest possible file
  • Shows the exact size reduction in kilobytes and percent
  • Runs in your browser, so your source code is never uploaded

Common use cases

  • Shrink a script before deploying it to production
  • Reduce the size of an inline snippet for a web page
  • Compress a small library you maintain by hand
  • Compare how much mangling saves on your codebase
  • Quickly minify code without setting up a build tool

Related Developer Tools

Explore all Developer Tools.