Developer Tools
JavaScript Minifier
Compress and minify JavaScript code instantly in your browser with Terser. See exact size savings with gzip estimates. No server upload, 100% private.
Free Online JavaScript Minifier — Compress & Optimize JS
What Is JavaScript Minification?
JavaScript minification is the process of removing unnecessary characters from JavaScript source code to reduce file size without changing its functionality. This includes stripping comments, whitespace, line breaks, and optionally renaming local variables to shorter names (mangling). Our free JavaScript minifier uses Terser — the same production-grade minifier used by Webpack, Vite, and Rollup — running entirely in your browser via a Web Worker for complete privacy and zero server dependency.
How to Use This JavaScript Minifier
Paste your JavaScript code into the input editor or drag and drop a .js file. Configure options — toggle mangling, compression, dead code elimination, and console removal. Click "Minify" to process the code. The output panel shows the minified JavaScript. A size bar displays original size, minified size, estimated gzip size, and percentage savings. Copy the result or download it as a .min.js file.
Key Features
- Terser engine — same production minifier used by Webpack, Vite, and Rollup
- Web Worker processing — runs in a background thread, does not freeze the UI
- Size comparison — original, minified, and estimated gzip sizes with percentage savings
- Configurable options — toggle mangling, compression, dead code removal, and console stripping
- Syntax highlighting — CodeMirror editor for both input and output
- 100% client-side — your code never leaves your browser
How Minification Works
Terser performs several optimization steps. Whitespace removal strips all unnecessary spaces, tabs, and newlines. Comment removal eliminates all comments except those marked with /*! */ license notices. Variable mangling renames local variables and function parameters to shorter names (e.g., calculateTotal becomes c) while preserving global references and property accesses. Dead code elimination removes code that can never be reached. Compression applies code pattern optimizations like converting if(x)return true to return!!x.
Common Use Cases
- Frontend developers — compressing JavaScript before manual deployment
- Quick size checks — seeing how much a script can be reduced before setting up build tooling
- Learning optimization — understanding what Terser does to your code
- Legacy projects — minifying scripts in projects without modern build pipelines
- Email and ad scripts — minimizing inline JavaScript that must fit within size constraints
Tips and Best Practices
Always test minified JavaScript by running it in the browser — while Terser is highly reliable, edge cases with eval(), Function.name, or unusual code patterns can occasionally cause issues. Disable mangling if your code accesses local variable names dynamically. Keep the "Remove console" option enabled for production builds to eliminate debug logging. For the most accurate real-world size estimate, look at the gzip size shown by the tool rather than the raw minified size, since all modern web servers deliver JavaScript with gzip or Brotli compression. Store your original source code in version control and generate minified files as part of your build process.