JS Minifier & Beautifier

Minify JavaScript with Terser, or format minified code with indentation.

Options
Minified

Examples

Questions

What does "Rename variables" change?

With it on (the default), local variables and parameters get the shortest names possible. That's where most of the savings come from after removing whitespace. Turn it off to keep your names, so the output stays readable.

Why do minify and beautify use different libraries?

Minifying has to parse the code to rewrite it safely, so it uses Terser. Beautifying only reprints the code with indentation. Each library is loaded only when you use it.

What happens with invalid JavaScript?

Minifying needs valid code, so a syntax error is shown with its line and column. Beautifying is more forgiving and reprints what it can.

Does minifying change what the code does?

No. Terser removes whitespace and comments, shortens names, folds constants and drops dead code, all without changing behavior.