JavaScript Minifier

Minify JavaScript code online. Strip comments and whitespace to reduce JS file size for production.

About this calculator

Paste JavaScript and minify it by removing comments and whitespace. Use it for small scripts, snippets and bookmarklets.

For large production bundles use a build tool; this page is for quick jobs.

How to use it

  1. Paste your JavaScript.
  2. Press Minify JS.
  3. Press Copy.

What it does

This minifier removes comments and unnecessary whitespace. It does not rename variables or restructure code, so it is safe but gives smaller savings than a full tool such as Terser or esbuild. Always test the minified output, and keep your readable source.

Worked example

Before // add\nfunction add(a, b) { return a + b; }

Afterfunction add(a,b){return a+b;}

Tips and common mistakes

  • Missing semicolons can break minified code; add them first.
  • Keep source maps in real projects.
  • Test after minifying.
  • Avoid minifying already minified files.
  • Don't minify code with regular expressions or template strings you haven't checked.

Frequently asked questions

What does minifying JavaScript do?

Removes comments and whitespace to reduce file size.

Is it the same as obfuscation?

No.

Will it rename variables?

No, only whitespace and comments go.

How much will I save?

Typically 20 to 50%.

Does it work for ES6?

Yes for simple removal, but test the result.

Is it free?

Yes.

Related tools