JavaScript Minifier
Minify and compress JavaScript code
Input JavaScript
JavaScript Minification Tips
β’ Always test your minified JavaScript thoroughly before deploying to production
β’ Keep original source files for debugging purposes
β’ Use name mangling with caution - it can break code that relies on function/class names
β’ Combine minification with gzip/brotli compression for best results
β’ Consider using build tools for automated minification in production
About JavaScript Minifier Tool
Our free online JavaScript minifier compresses your JS code by removing whitespace, comments, and unnecessary characters to produce the smallest possible output. Powered by Terser, the industry-standard JavaScript compression engine, this tool handles modern ES6+ syntax including arrow functions, template literals, classes, destructuring, and more.
Choose from three minification levels to match your needs. The Safe preset keeps all comments and variable names intact. The Recommended preset strips comments and debugger statements while preserving console logs. The Aggressive preset enables full name mangling, dead code elimination, and console log removal for maximum file size reduction.
All processing runs directly in your browser using the Terser library -- your JavaScript code is never uploaded to any server. The tool provides detailed compression statistics showing original size, minified size, bytes saved, compression percentage, and line count reduction. Simply paste your code, choose a preset, and get optimized JavaScript instantly.
Key Features
- Terser-powered minification with full ES6+ JavaScript syntax support
- Three minification presets: Safe, Recommended, and Aggressive compression levels
- Dead code elimination to remove unreachable code paths
- Optional console.log and debugger statement removal
- Variable name mangling (shortening) in Aggressive mode for maximum compression
- Real-time auto-minification with debounced processing as you type
- Detailed compression statistics: original size, minified size, bytes saved, ratio, and line count
- Built-in syntax validation with bracket and parenthesis matching
- JavaScript file upload (.js) support for processing existing scripts
- One-click copy to clipboard and download as .js file
How to Use the JavaScript Minifier
- Select a minification level: Choose Safe for basic compression, Recommended for balanced optimization, or Aggressive for maximum file size reduction with name mangling.
- Input your JavaScript: Paste your JS code into the text area, upload a .js file, or click Load Sample to try a demonstration.
- Wait for processing: The tool automatically minifies your code after a short delay, showing a processing indicator during compilation.
- Review compression results: Check the statistics panel to see how much file size was reduced, including original and minified sizes, bytes saved, and line count.
- Copy or download: Click Copy to copy the minified JavaScript to your clipboard, or use Download to save it as a .js file.
Use Cases
- Production deployment: Minify JavaScript before deploying to reduce file sizes and improve page load speed.
- Performance optimization: Compress scripts to improve Core Web Vitals, Time to Interactive, and First Contentful Paint metrics.
- Bandwidth reduction: Smaller JS files reduce hosting costs and data transfer, especially for high-traffic websites.
- Mobile optimization: Compressed JavaScript loads faster on mobile networks, improving the experience for mobile users.
- Quick one-off minification: Minify individual scripts when you need a quick optimization outside of your build pipeline.
- Code review and analysis: Use the compression statistics to assess how much optimization potential your codebase has.
- Learning and experimentation: Understand how minification works by comparing before-and-after output across different preset levels.
Frequently Asked Questions
Is this tool free?
Yes, the JavaScript Minifier is completely free to use with no limits on file size or number of minifications. No registration or account is required.
Is my data secure?
All minification happens directly in your browser using the Terser library. Your JavaScript code is never sent to any server, ensuring complete privacy and security of your source code.
What is the difference between Safe, Recommended, and Aggressive modes?
Safe mode performs basic compression while keeping all comments, console logs, and variable names. Recommended removes comments and debugger statements. Aggressive enables name mangling, console removal, dead code elimination, and multi-pass optimization for the smallest output.
Will name mangling break my code?
Name mangling renames local variables to shorter names, which is safe for most code. However, it can cause issues if your code relies on function or variable names at runtime (e.g., through eval or reflection). Always test thoroughly after using Aggressive mode.
Does this support TypeScript or JSX?
This tool processes standard JavaScript (ES6+). TypeScript and JSX need to be compiled to plain JavaScript first before minification. Use your TypeScript compiler or Babel to transpile, then paste the output here.
Tips & Best Practices
- Always keep source files: Store your original, unminified JavaScript in version control and only minify for production builds.
- Generate source maps: Use source maps in your build pipeline to debug minified code in browser developer tools.
- Test after minification: Always run your test suite against minified code, especially when using Aggressive mode with name mangling.
- Combine with server compression: Pair JavaScript minification with gzip or Brotli compression on your web server for the best file size reduction.
- Start with Recommended: The Recommended preset offers the best balance of safety and compression for most projects.
- Remove console logs in production: Use Aggressive mode to automatically strip console.log statements that should not appear in production code.
Related Tools
JSON Formatter/Validator
Format, validate and beautify JSON data
JWT Decoder
Decode and inspect JSON Web Tokens with claim explanations
Base Converter
Convert numbers between binary, octal, decimal, hex
Chmod Calculator
Calculate Linux file permissions in octal and symbolic
HTML Minifier
Minify HTML code by removing comments and whitespace
htaccess Generator
Generate Apache .htaccess files for redirects and security
JSON Tree Viewer
Professional JSON tree visualization and editing tool
CSS Minifier
Minify and compress CSS code
Regex Tester
Test and validate regular expressions
Code Beautifier
Format and beautify HTML, CSS, JavaScript code
API Response Formatter
Format and beautify API responses
SQL Query Builder
Build SQL queries visually
Last Added Free Tools
Citation Generator
Generate citations in APA, MLA, Chicago, and Harvard formats
Subnet Calculator
Calculate IPv4 subnets, network ranges, and CIDR notation
Markdown Editor
Write and preview Markdown with live rendering and toolbar
Mortgage Calculator
Calculate monthly mortgage payments, interest, and amortization schedule
Salary Calculator
Calculate take-home pay with federal and state tax deductions
ROI Calculator
Calculate return on investment and annualized returns
Inflation Calculator
Calculate how inflation affects purchasing power over time
DCA Calculator
Simulate dollar-cost averaging strategy and compare with lump sum
Crypto Profit Calculator
Calculate crypto trading profit, loss, ROI, and fees
Savings Goal Calculator
Plan how much to save monthly to reach your financial goal
Retirement Calculator
Project retirement savings and required income for retirement
WCAG Contrast Checker
Check color contrast ratios for WCAG AA and AAA accessibility compliance