JavaScript Minifier — Minify JS Online Free
Paste your JavaScript and minify it instantly. Remove comments, collapse whitespace, and reduce file size.
How to javascript minifier
- 1Paste or type your JavaScript code into the input textarea
- 2Click the Minify button to process the code
- 3Review the minified output and the before/after size comparison
- 4Click Copy to copy the minified JavaScript to your clipboard
About This Tool
JavaScript minification removes unnecessary characters from source code while preserving its
functionality. This includes single-line comments (//), multi-line comments
(/* */), extra whitespace, and redundant newlines. Smaller JS files download faster
and improve page load performance.
This is a basic, regex-based JavaScript minifier suitable for quick tasks and simple scripts. It does not rename variables, tree-shake dead code, or perform advanced optimizations. For production builds, use dedicated tools like Terser, esbuild, or SWC that understand JavaScript syntax deeply and can apply aggressive, safe transformations.
All processing happens entirely in your browser. Your JavaScript code is never sent to any server, making it safe to use with proprietary source code.
Frequently Asked Questions
This tool performs basic whitespace and comment removal, which is safe but not thorough. For production use, consider Terser or esbuild which can also mangle variable names and eliminate dead code while handling edge cases correctly.
The tool removes comments and collapses whitespace, which should not alter behavior. However, if your code relies on string literals containing comment-like patterns, edge cases could occur. Always test after minification.
The regex-based approach works on any text, including modern JavaScript with arrow functions, template literals, optional chaining, and other ES6+ features. It does not parse the AST.
Comment and whitespace removal typically saves 20-40% depending on how well-commented and formatted the source code is. Variable mangling (not done here) would save an additional 10-30%.