Home › Developer Tools › JavaScript Minifier

JavaScript Minifier

Paste JavaScript and get a smaller file that works exactly the same, with the size saving shown.

Open a .js,.mjs file or paste below

How to use JavaScript Minifier

  1. Paste your JavaScript or open a file.
  2. The minified code appears straight away, with the size before and after.
  3. Copy it or download the file.

How it works

The code is read by acorn, a full JavaScript parser. That means strings, regular expressions, template literals and code that relies on automatic semicolons are handled exactly. Comments and unnecessary whitespace are removed, and the result is parsed again to make sure it is still valid.

What it doesn't do

Variable names are not shortened. That keeps the minified code safe and readable in error messages; tools like Terser in a build step can squeeze out a little more. For most scripts, whitespace and comments are the bulk of the savings.

Why minify

Smaller files download faster, especially on mobile data, which helps page speed scores like Core Web Vitals. Keep your original, readable file for editing and publish the minified copy.

Frequently asked questions

Is my code uploaded?

No. Everything runs in your browser.

Can I undo the minification?

Use the Code Beautifier to make minified code readable again (comments can't be brought back).

Will it break my code?

Code is parsed before and after, so invalid output is never produced. If your code has a syntax error, you are told where.

Is there a size limit?

No fixed limit; very large files just take a moment longer.

Related tools

More Developer Tools