JS Minifier

Compress JavaScript by removing comments, whitespace, and unnecessary characters to reduce file size and improve load performance.

Input JavaScript
Minified JavaScript
⚠️ This is a basic minifier. It removes comments and collapses whitespace but does not rename variables or perform dead-code elimination. For production use, consider a full-featured bundler like esbuild or Terser.

About JS Minifier

JavaScript minification reduces file size by stripping developer-facing content that the browser doesn't need — comments and indentation whitespace. This tool performs safe, comment-aware minification that respects string literals and regex patterns so the output code is functionally equivalent to the input.

What this tool does

  • Removes single-line comments — Strips // ... comments (safe, aware of strings).
  • Removes block comments — Strips /* ... */ blocks.
  • Collapses whitespace — Replaces multiple spaces and newlines with a single space where safe.

How to Use

  1. Paste your JavaScript into the input area.
  2. Click Minify — the compressed JavaScript appears in the output.
  3. The tool shows the original vs. minified size and compression ratio.
  4. Click Copy to copy the minified code for your project.

How It Works

The minifier removes comments, strips unnecessary whitespace and newlines, shortens variable names where safe, and removes optional semicolons. The resulting code is functionally identical but significantly smaller.

Example

A 50KB script typically minifies to 20–30KB — a 40–60% reduction. Combined with gzip compression on your server, the delivered payload can be as little as 10–15KB.

FAQ

This tool is string-literal aware so it won't accidentally remove comment-like content inside strings. However, it does not parse the full JS AST. For complex code with regex literals, test the output. For production, use esbuild or Terser.
No. All processing runs in your browser. Your JavaScript is never transmitted anywhere.