Free No sign-up Client-side

JavaScript Minifier

Compress JavaScript with Terser — dead code dropped, local variables renamed, whitespace gone — so your scripts download and parse faster.

InputJavaScript
Output
Input: 0 lines · 0 charsOutput: 0 lines · 0 chars Processed locally in your browser

More than deleting whitespace

Minifying JavaScript isn't just about removing spaces and newlines. A real JS minifier parses your code into a syntax tree and rewrites it: it shortens local variable names to single letters, evaluates constant expressions, removes code that can never run, and collapses everything onto as few characters as possible.

This tool uses Terser, the compressor that powers the production builds of most modern bundlers. Before it runs, your code is checked for syntax errors with the engine's own parser, so an unterminated string or a stray bracket is reported up front rather than producing garbage.

All of this happens in your browser. Paste unreleased product code freely — Terser runs on your machine and nothing is uploaded.

From source to shipped, in four steps

  1. 1

    Paste your JavaScript

    Drop your script into the input pane, or upload a .js file.

  2. 2

    Pass the syntax check

    The code is validated first; if it won't parse, you get the error and line number.

  3. 3

    Let Terser compress it

    Names are mangled, dead code is dropped, and whitespace is removed in the output pane.

  4. 4

    Copy or download

    Take the minified script to your clipboard or save it as a .js file.

Why minify JavaScript

Smaller, faster bundles

Less JavaScript to download and parse means scripts become interactive sooner, especially on mobile.

Mangling beats whitespace removal

Renaming local variables to a, b, c saves far more than stripping spaces ever could.

Dead code removed

Unreachable branches and unused expressions are eliminated, so users never download logic that can't run.

Validated before output

A syntax check runs first, so you find out about a typo before it ships in a bundle.

Before and after

Readable source on the left; Terser's compressed output on the right.

Source → minified
// add two numbers
function add(a, b) {
  return a + b;
}
const numbers = [1, 2, 3];
const total = numbers.reduce((sum, n) => add(sum, n), 0);
console.log(total);
function add(o,n){return o+n}const numbers=[1,2,3],total=numbers.reduce((o,n)=>add(o,n),0);console.log(total);

Minified is not obfuscated

People often conflate the two, but they're different goals. Minification optimises for size and happens to make code hard to read as a side effect. Obfuscation deliberately scrambles code to resist reverse-engineering, often making it larger and slower. Terser minifies — it won't hide your logic from a determined reader, and it isn't a security measure. If you need to read minified output, expand it again with a JavaScript beautifier.

Good candidates for this tool

  • A small library or widget you want to embed inline without a build step.
  • A snippet for a bookmarklet, where every byte of the URL counts.
  • Quick experiments where you want to see how much a chunk of code compresses.
  • Vendor scripts you want to shrink before pasting into a page template.

Frequently asked questions

It uses Terser, the same minifier that ships inside most modern JavaScript bundlers. The output matches what you'd get from a production build step.

Terser is conservative with names it can't prove are local — globals and exports are generally preserved so they remain accessible. Local variables inside functions are renamed freely.

No. Minification optimises for size; the unreadability is a side effect. Obfuscation deliberately scrambles code to resist reverse-engineering. Terser does the former, not the latter, and isn't a security tool.

Your code is parsed before compression. If it contains a syntax error — a missing bracket or an unterminated string — you'll get the message and line number. Fix it and run again.

Yes. Terser understands modern features like arrow functions, async/await, optional chaining and template literals, and compresses them correctly.

No. Terser runs entirely in your browser, so even proprietary or unreleased code stays on your machine.

Need another tool?

Browse the full toolbox or dig into the blog for the engineering behind it.

Call UsWhatsApp