JS Minify
Minify your JavaScript code
Source code
Minified JavaScript
The result will appear here.
About this tool
This tool shrinks a JavaScript file before you ship it, so your pages have less data to download. It comes in handy for a standalone script, an embeddable widget, a bookmarklet or a project without a build step, when you want a lighter file without setting up webpack, Vite or esbuild just for that.
Minification is handled by Terser with compression and variable name mangling enabled, so the code is actually parsed rather than rewritten with regular expressions. Once it is done, the tool shows the size before and after along with the percentage saved. If there is a syntax error, the message points to the line and column.
How to use it
- Paste your code into “Source code” or choose a .js file under “Import a file”.
- Click “Minify JavaScript”.
- Check the output and the size savings under “Minified JavaScript”.
- Click “Download Minified JS” to get the minified.js file.
Frequently asked questions
Is my code sent to a server?
No. Terser is loaded into the page and minification runs in your browser. Imported files are read locally, and the minified file is created on your device when you download it.
Can minification break my code?
Terser applies transformations designed to preserve behavior, but it renames local variables. Code that relies on a function’s name, for example through fn.name, may be affected. Always test the minified file before publishing it.
What happens if my code has an error?
If Terser cannot parse the code, no output is produced and a message shows the error with its line and column. Fix the source file, then click the minify button again.
Does the tool generate a source map?
No, it only produces the minified code. If you need source maps to debug in production, run Terser or your bundler from the command line, where that option is available.