JavaScript minifier

Paste JavaScript to remove comments and unneeded spaces and line breaks. This is whitespace and comment minification only: variable names and code stay exactly as you wrote them.

Saved 34% (149 → 99 bytes).

Runs in your browser: nothing you enter is sent anywhere.

How to use it

  1. Paste your script on the left.
  2. Copy the minified result. The line under it shows how many bytes were saved.
  3. Tick the box if /*! … */ license comments must stay.

What it changes

  • Removes // and /* */ comments.
  • Removes indentation, blank lines and spaces around operators and brackets.
  • Keeps one space only where two words or symbols would otherwise fuse: return x, a + +b becomes a+ +b, and a number followed by . as in 1 .toString().

What it never changes

Names, string contents, template literals, regex literals, number formats, and the order of your code. It does not remove unused code or shorten anything.

Tips

Always keep your original source. For production bundles a full minifier gives smaller files; this tool is for quick snippets, bookmarklets and inline scripts where you want predictable output.

Frequently asked questions

Is this the same as Terser or UglifyJS?

No. Those tools also rename variables and rewrite code, which saves more space but needs a full parser. This tool only removes comments and whitespace, so the result is always the same program, just smaller.

Will it break my strings or regular expressions?

No. The tokenizer reads strings, template literals (including their ${ } parts) and regex literals as whole units and copies them unchanged, so spaces and // inside them survive.

What happens to code without semicolons?

Line breaks are kept wherever removing them could change how JavaScript inserts semicolons, for example before a line that starts with ++ or between two statements. Breaks after tokens like { , ; or = are removed.

Can it get a slash wrong?

A / after ) ] or } is read as division. In the rare case where a regex literal starts a statement right after a closing brace, the result may be wrong, so test the minified code. A / after an identifier, number or string is division; after other operators and keywords like return it starts a regex.

Does it support TypeScript or JSX?

It only knows JavaScript token rules. TypeScript without types erased and JSX can contain characters that look like regex or comments to it, so use it on plain JavaScript.

More in Developer

All tools in this category: Developer ·Updated November 3, 2026

Privacy choices

Google Analytics shows us which tools are used and whether they work. It may set cookies. Your choice is kept in this browser.