FreeOnlineQR

JavaScript Minifier

Remove the comments and indentation from JavaScript to make it smaller. This one is deliberately conservative, and it is worth knowing why: joining two lines of JavaScript can change what the code does, because of automatic semicolon insertion. A `return` with its value on the next line returns undefined; put them on one line and it doesn't. Getting that right requires a full parser, so this tool removes what it can remove safely and keeps every line break.

Result

Nothing is uploaded — this tool runs inside your browser, so your files never leave your device.

Help us improve

Why use this tool

  • Removes comments and all leading and trailing whitespace
  • Keeps line breaks, so automatic semicolon insertion cannot change behaviour
  • Never touches the inside of a string, template literal or regular expression
  • Reports the before and after size, and the percentage saved

How it works

  1. 1Paste the JavaScript you want to shrink.
  2. 2Copy the result, or download it as a file.
  3. 3For production, use a real bundler — see the answer below.

JavaScript Minifier — frequently asked questions

Because doing that safely requires parsing the code, and doing it unsafely silently breaks it. JavaScript inserts semicolons at line ends under specific rules, so removing a line break can change the meaning of the program — most famously with `return`, where the value on the next line is simply discarded once they are joined. Removing comments and indentation is the largest saving available without that risk.

Explore the other tools

Same deal everywhere on the site — free, no sign-up, and no watermark on anything you download.

Or see every tool on one page.