JavaScript Minifier
Minify JavaScript online — strip comments and whitespace to reduce bundle size.
Input JavaScript
Minified Output
Why Minify JavaScript?
JavaScript is usually the biggest bottleneck in web performance. It has to be downloaded, parsed, compiled, and executed — all before your page becomes interactive. Every kilobyte counts. Minification strips the parts humans need (comments, whitespace, readable names) while keeping everything the browser needs.
A typical JavaScript file shrinks 30-60% after minification. That's not just faster downloads — it's faster parsing too. V8 (Chrome's JS engine) parses minified code faster because there's less text to process. For mobile users on slow connections, the difference between 200KB and 100KB of JS can mean seconds of load time.
This tool handles comment removal, whitespace collapsing, and basic operator spacing. For production use, build tools like Terser, esbuild, or SWC provide advanced optimisations like dead code elimination, tree shaking, and variable mangling.
What Minification Removes
| Element | Before | After | Savings |
|---|---|---|---|
| Comments | // Calculate total /* Multi-line */ | (removed) | 10-30% of file typically |
| Whitespace | Indentation, blank lines | Collapsed to minimum | 15-25% of file |
| Line breaks | One statement per line | Everything on fewer lines | 5-10% of file |
| Variable names* | calculateTotalPrice | a | Significant for large files |
| Dead code* | Unreachable branches | (removed) | Varies widely |
What this means for you: Items marked with * require advanced AST-based minifiers (Terser, esbuild). This online tool handles comments and whitespace — the quick wins that don't risk changing behaviour. Use it for one-off jobs; use build tools for production.
JavaScript Minifier Comparison
| Tool | Speed | Compression | Best For |
|---|---|---|---|
| Terser | Moderate | Excellent (AST-based) | Webpack/Vite production builds |
| esbuild | Very fast (Go) | Very good | Speed-critical CI/CD pipelines |
| SWC | Very fast (Rust) | Very good | Next.js, modern frameworks |
| UglifyJS | Slow | Good (ES5 only) | Legacy projects |
| Google Closure | Slow | Best (advanced mode) | Maximum compression, type-aware |
Real-World Size Savings
| Library | Original | Minified | Minified + Gzip |
|---|---|---|---|
| jQuery 3.7 | 282 KB | 87 KB (69%) | 30 KB |
| React 18 | 140 KB | 45 KB (68%) | 14 KB |
| Lodash | 544 KB | 71 KB (87%) | 25 KB |
| Three.js | 1.2 MB | 650 KB (46%) | 170 KB |
| Typical app bundle | 500 KB | 200 KB (60%) | 65 KB |
Minification alone cuts 50-70%. Add Gzip/Brotli compression (which your server should already enable) and you're typically looking at 85-90% total reduction. That 500 KB bundle becomes 65 KB over the wire.
Related Tools
How to use this tool
Paste your JavaScript into the input area
Click Minify JavaScript to compress
Copy the result or download as a .min.js file
Common uses
- Reducing JavaScript file size for production
- Stripping comments from code before deployment
- Quick minification for inline scripts
- Comparing file sizes before and after compression
Share this tool