JS Minifier

Minify JavaScript with Terser

Compress JavaScript with Terser: whitespace and comments removed, variables shortened and dead code dropped. Syntax errors are reported with their exact line and column.
Try an example:

Output will appear here...

About JS Minifier

How it works

  1. Terser parses your code into a syntax tree - so it understands the code rather than just deleting spaces.
  2. It applies safe optimisations in two passes: removing dead code, joining declarations, simplifying expressions.
  3. Local variable names are shortened to single letters (mangling); public names are left alone.
  4. The result is printed without unnecessary whitespace. Syntax errors stop the process and are shown with the exact location.

What you need

  • Valid modern JavaScript (ES2020+ syntax is supported).

Tips

  • Minify as part of your build, and keep the original code for debugging.
  • Turn off "Shorten variable names" if other scripts depend on your top-level function names.

Limitations

  • TypeScript and JSX must be compiled to JavaScript first.

Runs in your browser. Everything happens in your browser - your code and data are never uploaded.

Frequently asked questions

Will minified code behave the same?+

Yes - Terser only applies transformations that keep the behaviour identical. Code that relies on function.name or reads its own source text is the rare exception.