JavaScript minifier
Shrink JavaScript files and see exactly how much you saved.
Runs in your browser. Nothing you type is sent anywhere.
- Shortens variable names
- Shows bytes saved
- Nothing uploaded
How to minify JavaScript
- Paste your JavaScript.
- Turn off Compress or Shorten variable names if you need to keep them readable.
- Copy or download the minified file.
What Compress and Shorten variable names each do
| Option | What it does |
|---|---|
| Compress | Removes dead code and simplifies expressions |
| Shorten variable names | Renames local variables to short names like a, b and c |
What stays the same either way
- Public behavior: the same inputs still produce the same outputs.
- Every string in the code, including any text shown to users.
- The order operations run in.
- A /*! ... */ comment, since Terser keeps that style by default, which is the convention many libraries use for license banners.
Tips for minifying JavaScript
- Keep an unminified copy, or generate a source map in your build tool, so production errors are still readable.
- Turn off Shorten variable names for a library other developers will read, so error messages keep meaningful names.
- Run tests against the minified output before shipping it, since a rare edge case in a minifier is still possible even though this one is widely used.
JavaScript minifier FAQ
Is minified JavaScript still valid code?
Yes. It runs exactly the same as the original, just with shorter names and no extra whitespace.
How much smaller does JavaScript usually get?
Often 30 to 60 percent smaller, depending on how many comments and long variable names the original has.
What happens if my code has a syntax error?
The error is shown with the line and column where it happened, so you can fix it and try again.
What is the difference between Compress and Shorten variable names?
Compress rewrites the code to remove dead branches and simplify expressions. Shorten variable names renames local variables to single letters. Turn either off on its own.
Can this minify modern syntax like async and arrow functions?
Yes, including ES2020 and later syntax such as optional chaining and async or await.
Which minifier does this use?
Terser, the standard successor to UglifyJS and the minifier most bundlers, including webpack, Rollup and esbuild, use by default.
Can minifying ever break my code?
It should not change behavior for normal code. Code that reads a function or variable's original name at runtime, for example through non-standard introspection tricks, can break once names are shortened. Turn off Shorten variable names if that applies to you.
Does it support TypeScript syntax?
No, this expects plain JavaScript. TypeScript's type annotations are not valid JavaScript and will cause a syntax error here, so compile TypeScript to JavaScript first.