JavaScript Minifier
JavaScript Minifier
A conservative, line-based minifier: strips comments and blank lines and trims indentation. It never renames variables and never removes semicolons.
The JavaScript Minifier shrinks scripts the safe way: it removes comments and blank lines and trims leading indentation, line by line, without ever renaming variables, joining statements, or dropping semicolons. Aggressive minifiers squeeze more bytes but need a full parser and can surprise you; this conservative approach keeps your code's shape and meaning exactly intact while still cutting obvious fat.
The limits are stated honestly. Because the tool works line by line, it will not rename identifiers, remove unreachable code, or pack statements onto one line, so its savings are smaller than a build pipeline's. In return, what comes out is what went in, minus comments and empty space, and it stays readable enough to debug.
One practical caution: like other simple comment strippers, it treats a double slash after code on the same line as a comment start, with basic guards for strings; if your code builds URLs in unusual ways, review the output once. Everything runs in your browser and nothing is uploaded.
How to use
- Paste your JavaScript into the box.
- Click Minify JavaScript.
- Check the byte saving in the status line.
- Copy the result and test it once in your page.
- Keep the original, commented file as your editing version.
Frequently asked questions
Why not minify as aggressively as build tools?
Renaming variables and removing code safely requires parsing the whole program and understanding scope. Doing that badly breaks code. This tool chooses the safe subset that works in a browser page.
Are semicolons ever removed?
Never. Semicolons are left exactly where they are, so automatic-semicolon-insertion edge cases cannot change your program's meaning.
Does it remove block comments?
Yes, multi-line block comments are removed before line processing. Single-line comments are also removed, with simple protection for common string cases.
Is my code uploaded?
No. Minifying runs locally in your browser only.