JS Minifier
Minify JavaScript source code
About JS Minifier
Minifies JavaScript with Terser, which parses the code, removes comments and unreachable code, shortens expressions and renames local variables, then shows the size before and after. You can turn off Mangle names or keep license comments marked /*! or @license, and ES modules are detected so their top-level names get shortened. It runs client-side on one file at a time, without bundling imports or generating source maps.
Category: Minifiers.
Frequently asked questions
What does the JS minifier change in my code?
▾
Terser removes comments and whitespace, drops unreachable code and unused local variables, and rewrites expressions into shorter equivalents, such as turning simple if statements into && or ternaries. With Mangle names on, local variables, parameters and local functions get one- or two-letter names. The values of strings, template literals and regular expressions never change, though quotes and escape sequences may be rewritten.
Is the minified output safe to use in production?
▾
Yes for typical code: Terser parses the source and only applies transforms that keep its behavior, so URLs inside strings, regex literals and code without semicolons are handled correctly. Code that depends on function or class names at runtime, such as fn.name or constructor.name checks, can break when names are shortened, so turn off Mangle names for it.
How are ES modules and top-level variables handled?
▾
If the code has top-level import or export statements, or uses top-level await, it is minified as a strict-mode module: imports and exported names are kept, while other top-level names are shortened or removed when unused. Plain scripts keep their top-level names, since other scripts or inline handlers may use them as globals.
Can I undo minification or get a source map?
▾
Not fully. A formatter such as Prettier restores indentation and line breaks, but comments are gone and shortened names can't be recovered. This tool doesn't generate source maps, so use Terser, esbuild or your bundler's production build when you need them.