JS Minify
Minify and beautify JavaScript code with Terser. Remove comments, mangle variables, compress code, and optimize for production. Reduce file size by 30-60% for faster load times.
Minification Options
Recommended Settings
Best Practices
- •Always test minified code before deploying to production
- •Keep function/class names for better debugging in production
- •Remove console.log statements for production builds only
- •Use source maps to map minified code back to originals
Performance Tips
- •Minification can reduce file size by 30-60%
- •Smaller files mean faster downloads and parsing
- •Enable compression on your web server (gzip/brotli) for even more savings
- •Consider code splitting for large applications
Pro Tips
- •Use mangle for maximum file size reduction
- •Keep original source files - minification is irreversible
- •Test edge cases after minification (eval, dynamic properties)
- •Combine with tree-shaking and dead code elimination in build tools
Most Popular
Most users enable all options except 'Remove console.log' for debugging
When to Use This Tool
Minify JavaScript files before deploying to production to reduce bundle size and improve load times. Minification removes whitespace, shortens variable names, and optimizes code structure, resulting in 30-60% smaller files that load faster for users.
Recommended: Production
Optimize JavaScript for faster page load times and better user experience. Smaller JavaScript files mean faster downloads, parsing, and execution. Critical for mobile users and slow connections. Use minification as part of your build pipeline for optimal performance.
Recommended: Speed
Reduce bandwidth costs and server load by serving smaller JavaScript files. Minified code requires less data transfer, reducing hosting costs and improving server response times. Especially important for high-traffic websites or applications with large JavaScript codebases.
Recommended: Efficiency
How It Works
Paste your JavaScript code into the input textarea
Configure minification options based on your needs
Click 'Minify' to compress code or 'Beautify' to format it
Terser processes the code with your selected options
View detailed statistics showing size reduction and savings
Copy to clipboard or download the processed file
Test the minified code to ensure functionality is preserved
100% Private
Files never leave your device. All processing happens locally in your browser.
Lightning Fast
Powered by Terser (industry-standard JavaScript minifier) and js-beautify for optimal performance on modern browsers.
Open Source
Built with verified, open-source libraries. Fully transparent.
Frequently Asked Questions
Will minification break my JavaScript code?
Properly configured minification preserves functionality. However, code using eval(), dynamic property access with bracket notation, or relying on specific variable/function names may have issues. Test minified code before deploying. Enable 'Keep function names' and 'Keep class names' if you need to preserve identifiers for debugging or framework requirements.
What is variable name mangling?
Mangling replaces long variable and function names with short ones (e.g., myVariableName → a, calculateTotal → b) to reduce file size. This is safe for local variables but can break code that relies on function.name or uses eval(). Disable mangling if you need to preserve original names for debugging.
Should I keep function names for debugging?
Yes, if you need stack traces to show original function names in production errors. Keeping function names adds minimal size (~1-2%) but makes debugging much easier. For libraries or frameworks that inspect function names (like React DevTools), you must keep function and class names to maintain compatibility.
How much size reduction should I expect?
Typical reduction is 30-60% depending on your code style and options. Code with many comments and descriptive variable names sees the most reduction. Mangling adds 10-20% extra savings. Already-minified or very terse code may only see 10-20% reduction. Use the statistics panel to see exact savings.
Can I reverse minification?
You can beautify/prettify minified code to make it readable again, but you cannot recover original variable names, comments, or code structure. Always keep unminified source files. Source maps can help map minified code back to originals for debugging, but this tool focuses on minification only.
Should I remove console.log statements?
Yes for production, no for development. Console logs can expose sensitive information and impact performance. Enable 'Remove console.log' for production builds. Keep them during development for debugging. Use environment-based build configurations to automatically remove console logs in production.