JavaScript Minifier
Minify JavaScript code online. Paste your script, choose options such as removing comments and shortening variable names, and get compact code plus a compression ratio report.
FreeOnline Tool
Loading…
How to Use
- Paste your JavaScript into the input box on the left.
- Choose the minification options (remove comments, shorten variable names and so on).
- Click "Minify" to run it.
- Review the minified code and the compression ratio on the right.
- Click "Copy" to take the result for your production deployment.
Features
- Removes single-line and multi-line comments to cut dead bytes.
- Eliminates redundant whitespace, line breaks and semicolons.
- Optional variable name shortening (obfuscation) for further size reduction.
- Displays the before and after size along with the compression percentage.
- Supports modern ES6+ syntax and does not change the code's behavior.
Use Cases
Deploying production JavaScript
Compress readable development code before shipping it to a production server to cut bandwidth and speed up script downloads.
Optimizing CDN-hosted scripts
Minify shared JavaScript libraries served from a CDN to shorten load times worldwide and improve Core Web Vitals.
Fitting mini program size limits
WeChat mini programs cap the code package size, and minifying JavaScript keeps the bundle safely under the limit.
Sanity-checking build output
Compare hand-written code with the output of your build tool to confirm your minification strategy delivers what you expect.
FAQ
What is the difference between minification and obfuscation?
Minification mainly removes whitespace and comments to reduce size. Obfuscation goes further and shortens variable names to single characters, making the code harder to reverse engineer. Both options are available here.
What if the minified JavaScript throws an error?
Errors introduced by minification usually trace back to a syntax problem in the original code. Verify the source runs cleanly in the browser console first, then minify it.
Does it support ES modules with import and export?
Basic whitespace and comment removal works on module code. For full tree-shaking and deeper optimization, use a dedicated bundler such as Webpack or Rollup.
Does minification affect source map debugging?
This tool does not generate source maps. If you need to debug in production, configure source map generation in your build tool instead of minifying by hand.