Skip to content

Code tool

JavaScript Minifier

Paste JavaScript and minify it into a smaller file that behaves the same.

Runs entirely in your browser. Nothing you paste is uploaded.

Paste some JavaScript to get started.

JavaScript Minifier by YegappanFree tool. Open the full page for the guide.

How to use the JavaScript Minifier

  1. Paste your JavaScript into the left box, or load the sample.
  2. Choose the options you need, then select Minify.
  3. Copy the result or download it as script.min.js.

How JavaScript minification works

A JavaScript minifier makes a script smaller without changing what it does. This online JS minifier uses Terser, the engine most build tools rely on, so you can minify JS without setting up a project.

This tool runs Terser, the minifier used by most build tools. It parses your code, so it understands modern syntax such as arrow functions, classes, optional chaining and async functions, and it reports syntax errors with the line and column.

Compress removes unreachable code and simplifies expressions. Shorten local variable names renames variables inside functions to one or two letters. Names at the top level are kept, so other scripts can still call your functions. Turn on ES module for files that use import or export, so unused top-level code can be removed and top-level names shortened too.

Minified code is typically 40 to 70 percent smaller. Keep your original source: minified code is hard to read and debug. The minifier itself is only downloaded when you first press Minify.

Common questions

How do I minify JavaScript online?

Paste the code and the minifier returns the compressed version, ready to copy into your file.

Will minified code still work?

Yes. Terser keeps the behaviour the same. Code that depends on function names or on reading its own source text is the rare exception.

Why did I get a syntax error?

The parser found code it could not read. The message shows the line and column, and the position is selected in the input box.

Does it support TypeScript or JSX?

No. Compile those to JavaScript first, then minify the output.

Is my code uploaded?

No. Terser runs in your browser, so your code never leaves your device.

Guides for the JavaScript Minifier

Related tools