JavaScript Minifier
Make scripts smaller and faster to load. Terser, the minifier behind most JavaScript build tools, shortens names, removes code that never runs and strips comments, while keeping what the code does.
How to minify JavaScript
- 1Paste your JavaScript or open a .js file.
- 2Choose whether to shorten names, simplify code and keep license comments.
- 3Copy the minified code or download it.
What it does
Local variable and function names become one or two letters, whitespace and comments go, and the code is simplified: unused variables and unreachable code are removed and constant expressions are worked out in advance.
Modules
Code with import or export statements is treated as an ES module automatically, which also lets top-level names be shortened.
Errors
If the code has a syntax error, you see the line and column with a pointer, which makes it a quick syntax checker too.
Frequently asked questions
- Is my code uploaded?
- No. Everything runs in your browser, so your code never leaves your device.
- Which comments are kept?
- With “Keep license comments” on, comments starting with /*! or containing @license or @preserve are kept; all others are removed.
- Can I minify TypeScript?
- Compile it to JavaScript first; Terser only reads JavaScript.