JavaScript Minifier

Minify JavaScript with Terser: strips whitespace and comments, shortens local variable names and applies safe compressions. Runs in your browser.

Output

Runs entirely in your browser. Your data is never uploaded.

Related Tools

View All

What is JavaScript Minifier?

The JavaScript Minifier compresses modern JavaScript (ES2015+) with Terser, the minifier used by webpack and Vite. It removes whitespace and comments, renames local variables to short names and simplifies expressions.

How to use JavaScript Minifier

  1. Paste your JavaScript into the input box.
  2. Click Minify (the output also updates while you type).
  3. Check the size line under the output.
  4. Copy or download the minified code.

Example

Input
function add(first, second) {
  return first + second;
}
console.log(add(1, 2));
Output
function add(d,n){return d+n}console.log(add(1,2));

When to use JavaScript Minifier

Use it for small scripts, bookmarklets, inline <script> blocks or quick size checks. For applications, let your bundler minify with source maps. It does not transpile TypeScript or JSX – strip types first.

How JavaScript Minifier works

The code is minified with terser.minify using compress and mangle enabled and all comments removed. Terser parses to an AST, inlines constants, removes dead code and unused variables in local scopes, and renames function-local identifiers. Top-level names are not mangled, so global functions keep their names. Syntax errors are reported with line and column.

Common Use Cases

  • Minifying a standalone script for a static site
  • Creating compact bookmarklets
  • Checking how small a library function gets
  • Removing comments before embedding code

Security Note

Everything runs locally in your browser; the code you paste is not uploaded.

FAQs

Why are my top-level variable names not shortened?

Top-level names may be used by other scripts, so Terser keeps them by default.

Does it support TypeScript or JSX?

No, input must be plain JavaScript.

Is a source map generated?

No; use your build tool when you need source maps.

Good next steps

Explore more categories