JavaScript minifier

With this JavaScript minifier, paste the code below: the tool removes comments and superfluous whitespace and shows how many bytes you save. Strings, template literals and regular expressions are left untouched; the result does the same as the original.

Source: Ecma International – ECMAScript Language Specification (§ 12.10 Automatic Semicolon Insertion). Updated: .

My Toolbox

Result

Result
function add(a,b){return a+b;} const numbers=[1,2,3];console.log(numbers.map((n)=>add(n,10)));
Summary
135 → 94 bytes (30.4 % smaller).
Only comments and whitespace are removed, variables are not renamed – the result is equivalent but larger than with Terser or esbuild.

How it is calculated

Minifying JavaScript means removing everything execution does not need: comments, indentation, spaces and line breaks. The tool splits the code in your browser into strings, template literals, regular expressions, numbers, words and symbols and puts it back together with the least possible whitespace. The file loads faster; its behaviour does not change.

How it works

  1. Paste JavaScript into the field.
  2. Decide whether licence comments (/*! … */, @license, @preserve) should stay.
  3. Copy the result; the display shows the size before and after.

What happens when minifying

Limits

For the strongest shrinking (shortening names, removing dead code, restructuring code) use Terser or esbuild in your build. This tool is meant for quick, safe shrinking without any setup.

Privacy

The code never leaves your browser. For stylesheets there is minify CSS; next steps: format HTML or test a regex.

Frequently asked questions

How can I minify JavaScript?

Paste the JavaScript into the field: the tool removes comments and whitespace and shows the saving. Copy the result into your file.

Does minifying change the behaviour of the code?

No. The tool only removes comments and whitespace and leaves strings, template literals and regular expressions unchanged. Line breaks stay where they replace a semicolon.

Are variable names shortened?

No. This tool does not rename anything. For the strongest shrinking use Terser or esbuild in your build.

How much does minifying save?

For commented, indented files often 20 to 50 percent. On top of that the server compresses with gzip or Brotli; both together make sense.

Can I make minified code readable again?

This tool only goes one way. For indenting code, editors or a code formatter are suitable.

Is my code uploaded?

No. Everything runs locally in your browser.

Sources and legal basis

As of: · Editorial policy

Related tools