JavaScript Minifier: Compress JS Code Online
Make JavaScript files smaller for faster pages. Press the button to minify; the engine loads only when you use it.
- Works on your device. Nothing is uploaded.
- Free, no watermark
- No signup
How to use
- Paste JavaScript or open a .js file.
- Choose whether to shorten variable names and compress code.
- Press "Minify JavaScript", then copy or download the .min.js.
Good to know
Minification uses Terser (BSD licence), the engine behind many build tools. "Shorten variable names" renames local variables to single letters; "Compress code" removes unreachable code and simplifies expressions. Top-level names are kept so other scripts can still call your functions.
If your code has a syntax error, you see the line and column and the parser message, so you can fix it. Licence comments starting with /*! or containing @license or @preserve are kept.
Files with import or export are treated as ES modules. Keep the original source and use a source map in real projects; this tool is for quick one-off files, snippets and small sites without a build step.
Questions
Why is there a button instead of live results?
Terser is a large engine. Loading it only when you press the button keeps the page fast.
Will my code still work?
Terser is widely used and safe for normal code. Test the result, especially code that relies on function names.
Does it obfuscate my code?
It makes code harder to read, but it is not protection. Anyone can format it back.
How much smaller will it be?
Often 30–60% smaller, depending on comments and names.
Is my code uploaded?
No. Terser runs in your browser.