All tools
Development tools

JavaScript Minifier

Compress JavaScript files for production — strip whitespace and comments, see the bytes saved, and copy the minified output instantly.

Remove whitespace Strip comments Mangle variables Size reduction % ES5 / ES6+ Copy output
Get started free Sign in

Free · No credit card · 50 credits/day

Minification techniques explained

Whitespace removal

Removes all spaces, tabs and newlines that are not inside strings. Safe, always done, biggest single saving.

💬

Comment stripping

Removes // line comments and /* block comments */. Safe except for copyright banners (which can be preserved with /*! */).

🔤

Variable mangling

Renames long variable names to 1–2 character names. Can save 20–50% additional bytes beyond whitespace removal.

📐

Dead code removal

Eliminates unreachable code paths — e.g. code after an unconditional return or inside if (false) {} blocks.

🔁

Constant folding

Pre-computes constant expressions at minification time (e.g. 60 * 60 * 24 → 86400) to reduce runtime work.

📦

String deduplication

Replaces repeated string literals with a single variable to reduce total bytes in large bundles.

Frequently asked questions

What is the difference between minification and uglification?

Minification removes whitespace and comments. Uglification (mangling) additionally renames variables from descriptive names to short ones (a, b, c) to save more bytes. Most production build tools do both. Mangling can break code that relies on function.name or uses eval().

Will minification break my JavaScript?

Whitespace removal and comment stripping are safe. Variable mangling can break code that checks function.name, uses eval(), or relies on argument names for dependency injection (older AngularJS). Always test minified output before shipping.

What is tree shaking and how does it differ from minification?

Tree shaking removes unused exports from ES modules — if you import a utility library but only use one function, tree shaking drops the rest. Minification shrinks the code that remains. They are complementary: tree shake first, then minify. Tree shaking requires ES module syntax (import/export).

Should I minify third-party libraries?

Most popular libraries already ship minified versions (e.g. react.production.min.js). If you bundle them with webpack/Vite, your build tool minifies them automatically in production mode. Re-minifying already-minified code rarely helps and can sometimes increase size.

Related dev tools

Minify the rest of your front-end stack.

CSS Minifier

Compress CSS stylesheets — strip whitespace, shorten colors and merge duplicate selectors.

HTML Formatter

Beautify or minify HTML — handles embedded scripts and styles too.

Diff Checker

Compare original and minified JavaScript to verify no logic was accidentally removed.

Compress your JavaScript now

Free account. 50 credits per day. Access to 75+ tools instantly.

Create free account →