About the JavaScript Minifier
Shrink JavaScript files with Terser, the minifier used by most build tools. Removes whitespace and comments, shortens variable names and simplifies code, and shows the size saved.
Key features
- Powered by Terser
- Removes whitespace and comments
- Shortens local variable names
- Compresses and simplifies code
- Keeps license comments if you want
- Shows the bytes saved
Make JavaScript files smaller
Smaller scripts download and parse faster, which improves page speed and Core Web Vitals. Minify a script before adding it to a site, or check how much smaller a file can get.
What minification does
| Technique | Before | After |
|---|---|---|
| Remove whitespace and comments | // add\nreturn a + b; | return a+b |
| Shorten local names | function total(price, qty) | function total(n,r) |
| Simplify expressions | if (x) { return true } else { return false } | return!!x |
| Drop unreachable code | Code after return | Removed |
Typical savings are 30–60% before gzip, depending on comments and naming.
Related tools
JavaScript formatter to reverse it, CSS minifier, and JSON minifier.
How to use the JavaScript Minifier
- Paste your code into the input box, upload a file, or click Sample to try it out.
- Choose the options you want, such as indentation, line width or dialect.
- The result appears instantly in the output panel. Syntax errors are shown with their line and column.
- Click Copy to copy the result, or Download to save it as a file.