JavaScript Minifier

Paste JavaScript to remove comments and unneeded whitespace, producing a smaller file that runs the same. Strings, template literals and regexes are protected. Everything runs in your browser — your code is never uploaded.

Paste JavaScript, then press Minify JS.

What minifying removes

JavaScript minification removes the parts the engine ignores — line comments (//…), block comments (/*…*/), indentation and surplus blank lines — leaving a compact file that runs byte-for-byte the same. Smaller scripts download and parse faster.

saved % = (original − minified) ÷ original × 100

This minifier is a fast, dependency-free whitespace compressor: it strips comments and collapses runs of whitespace while protecting strings, template literals and regular expressions, so text inside quotes is never altered.

Worked example

A commented helper collapses neatly:

Before: function add(a, b) { /* sum */ return a + b; } with comments and indentation.
After: function add(a,b){return a+b;}
Saving: often 30–50% on readable, well-commented source.

Limits and safety

This is a lightweight whitespace-and-comment minifier, not a full mangler — it does not rename variables or remove dead code the way build tools such as Terser do, so it is safe to run without a parser and won't break valid code. It keeps newlines where removing them could change meaning (after return, break, etc.) so automatic semicolon insertion still works. For production builds, a bundler will squeeze out more. Everything runs locally — your code never leaves the browser.

Tip: minifying styles or markup as well? Use the CSS minifier and the HTML minifier.

Frequently asked questions

Will minifying break my code?

No. This tool only removes comments and insignificant whitespace and keeps the newlines that matter for automatic semicolon insertion, so valid JavaScript keeps working exactly the same.

Does it rename variables?

No. Unlike full compressors such as Terser or UglifyJS, it does not mangle names or remove dead code — it is a safe whitespace minifier you can run without a build step.

Are my strings and regexes safe?

Yes. The minifier detects string, template-literal and regex contexts and leaves their contents untouched, so quoted text and patterns are never collapsed.

Is my code uploaded?

No. Minification runs entirely in your browser with string processing. Nothing you paste is sent to a server.

MB
Mustafa Bilgic · Editor, Calcool
A dependency-free whitespace/comment minifier that protects string, template and regex literals; it does not mangle identifiers. Everything runs in your browser - nothing you enter is uploaded, logged or stored.

Related calculators