JavaScript Minifier

Compress your JavaScript by removing comments, whitespace, and unnecessary characters for faster page loads.

⚡ Note: This is a lightweight whitespace/comment remover. For production use with advanced optimizations (variable renaming, dead code elimination, tree shaking), use tools like Terser, UglifyJS, or esbuild in your build pipeline.
0 original
0 minified
0% saved
00 lines
Input JavaScript
Minified Output
Minified JS will appear here...
Ad Space

Free Online JavaScript Minifier

Reduce your JavaScript file size by removing comments, whitespace, and unnecessary formatting. This lightweight minifier handles single-line comments (//), multi-line comments (/* */), extra whitespace, and blank lines while preserving string literals and regex patterns. For more aggressive optimizations like variable renaming and dead code elimination, use build tools like Terser or esbuild.

What This Tool Does

Removes all single-line comments (// ...) and multi-line comments (/* ... */). Collapses multiple whitespace characters into single spaces. Removes blank lines and trailing whitespace. Preserves string contents (both single and double quoted) and template literals. Maintains proper semicolons and line breaks where syntactically required.

When to Use This Tool

Quick minification of small scripts and snippets. Reducing inline script size in HTML pages. Compressing standalone JavaScript files without a build pipeline. Educational purposes — understanding what minification removes. For production applications with multiple files, use a proper bundler with built-in minification (Webpack + Terser, Vite, esbuild, or Rollup).

Frequently Asked Questions

Will this break my JavaScript?

This tool performs safe whitespace and comment removal. It preserves string literals, regex patterns, and syntactic structure. However, for complex code with edge cases, always test the minified output before deploying to production.

Does it rename variables?

No. Variable renaming (mangling) is an advanced optimization that requires full code parsing. This tool focuses on safe whitespace and comment removal. For variable renaming, use Terser or Google Closure Compiler.

How much space does JS minification save?

Comment and whitespace removal typically saves 20-40% of file size. Variable renaming (not done by this tool) can save an additional 10-20%. Gzip compression on top of minification saves another 60-70%, which is why both are recommended for production.