How to use the javascript minifier
- Paste JavaScript or open a .js file. Compile TypeScript or JSX to JavaScript first.
- Choose options: compress, mangle names, and keep function or class names if your code depends on them.
- Under advanced options, choose module or classic script mode and which comments to keep.
- Select Minify JavaScript. Syntax errors are shown with the line, column and a caret.
- Test the output, then copy it or download it as a .min.js file.
Worked example
Constant folding in module mode
The 104-byte input function add(first, second) { const total = first + second; return total; } console.log(add(2, 3)); minifies in module mode to console.log(2+3); (17 bytes), because Terser inlines the unused top-level function. In classic script mode the function must be kept, giving function add(d,n){return d+n} (51 bytes).
How it works
The code is minified by Terser, loaded into your browser on first use. Terser parses the code to a syntax tree, applies compression passes (dead code removal, constant folding, inlining), renames local identifiers when mangling is on, and prints compact output. Parse errors carry Terser's line and column, which are shown against your input.
Assumptions
- Module mode treats the input as an ES module (strict mode, top-level names are private). Classic scripts that define globals for other files should use script mode.
Frequently asked questions
Is my data uploaded?
No. This tool runs entirely in your browser. Your input is processed on your device and is not sent to our server or stored.
Why should I test the minified output?
Minification is safe for normal code, but code that reads function names, uses eval or with, or depends on global variable names can behave differently after mangling. Run your tests against the minified file.
What does "Keep function names" do?
It stops Terser from renaming or dropping function names, so fn.name and stack traces keep the original names. Frameworks that rely on names sometimes need it.
Does it create source maps?
No. For production builds with source maps, use Terser through your bundler (Vite, webpack, esbuild or Rollup).
Limitations
- No source maps.
- TypeScript, JSX and other syntaxes must be compiled first.
- Large bundles (several MB) can take a few seconds on slower devices.