JavaScript Minifier

Quickly strip comments and whitespace from JavaScript and see the size reduction.

Source Javascript
Local Processing Only
Optimized Output
Efficiency 0.0%
Bytes Saved 0 B

Paste some JavaScript and this tool removes its comments and surplus whitespace, then reports the compression ratio and how many bytes you saved. It's handy for shrinking a small script before pasting it into a page. Because minification matters most for real-world code, please read the honest caveat below: this is a lightweight text compressor, not a full compiler-grade minifier. It runs entirely in your browser.

How it compresses

The tool works by pattern-matching, not by parsing your code into a syntax tree. It removes /* … */ block comments and // line comments, collapses whitespace, and trims spaces around the characters { } ; : ,. That reliably shrinks simple, well-formed scripts and shows you the efficiency percentage and bytes saved so you can see the effect.

Important: test the output before you ship

A text-based minifier has real limits you should know about. Collapsing newlines can break code that relies on automatic semicolon insertion (statements that end at a line break rather than a ;), and the comment-stripping patterns can misfire on // or /* sequences that appear inside strings, template literals or regular expressions. It also can't rename variables or perform the dead-code elimination that tools like Terser or UglifyJS do. Treat this as a convenience for small snippets, always test the minified result, and for production builds prefer a proper minifier in your toolchain.

Frequently Asked Questions

Can this minifier break my code?

It can, on edge cases. Because it collapses whitespace with pattern matching rather than parsing the code, it may break scripts that depend on line breaks for semicolon insertion, or that contain // or /* inside strings or regexes. Always test the output.

Does it rename variables like Terser does?

No. It only removes comments and whitespace. It does not shorten variable names, inline functions or drop unused code, so its savings are smaller than a compiler-grade minifier such as Terser or UglifyJS.

What do the two result figures mean?

Efficiency is the percentage of characters removed (difference ÷ original), and Bytes Saved is that difference shown in B/KB/MB. They reflect character counts, not gzip-compressed transfer size.

Is my code sent anywhere?

No. Everything runs locally in your browser, so the script you paste never leaves your device.