Minify JavaScript with Terser, the same minifier behind most build tools. It strips comments and whitespace, shortens local variable names and simplifies dead code.
It handles modern syntax, including ES modules, optional chaining and private class fields.
How to use it
- Paste the code.
- Tick whether it is an ES module and choose the target.
- Copy or download the .min.js.
Frequently asked questions
- Why do I have to say whether it is an ES module?
- Because modules are always in strict mode and have their own scope. Told that, Terser can shorten names that in a classic script would be globals and off limits.
- Will shortening names break anything?
- Local names are safe. What does break is code that reaches them by string, such as a framework injecting dependencies by parameter name.
- It reports a syntax error the browser did not.
- Terser parses the whole file first. Often it is syntax newer than the chosen target: raise the target to ES2020 and try again.
Related tools
Minify CSSCSSO: it restructures and merges rules, not just strips spaces.
Count words and charactersA live count, reading time and the limits each platform imposes.
Change letter caseUPPERCASE, lowercase, Title Case, camelCase, snake_case and more.
Sort and clean up linesSort, drop duplicates and blanks, number or reverse a list.
URL encode and decodePercent-encoding, for whole addresses or for a single parameter.