JavaScript Minifier

Basic JavaScript minification: strip comments and collapse whitespace to reduce file size.

Processed in your browser. No data is sent to our servers.

How to Minify JavaScript

Paste your JavaScript source code into the editor, click Minify JavaScript, and the tool removes single-line comments, multi-line comments, and collapses unnecessary whitespace. The output panel shows original and minified sizes along with the percentage reduction. This is a lightweight, browser-based minifier intended for quick size checks and simple scripts. For production builds with advanced optimizations like dead-code elimination and variable mangling, use a dedicated build tool such as Terser or esbuild.

When to Use This Tool

This minifier is perfect for quick tasks: shrinking a snippet before embedding it in an HTML page, removing debug comments before sharing code, or estimating potential size savings. It handles the most impactful optimizations — comment removal and whitespace collapse — which typically account for 30 to 50 percent of the size reduction in well-commented code. The entire process runs in your browser with no server involvement, so your code stays private. For full production optimization, pair this with tree-shaking and module bundling in your build pipeline.

Frequently Asked Questions

No. This tool only removes comments and whitespace. Variable mangling requires a full minifier like Terser.

The minifier is conservative — it removes comments and whitespace but preserves all functional code. However, regex literals that look like comments could theoretically cause issues in edge cases.

Those tools perform advanced optimizations including variable renaming, dead-code elimination, and expression simplification. This tool handles basic whitespace and comment removal only.