What Does the JavaScript Minifier Do?
The JavaScript Minifier reduces script file size by stripping comments and collapsing unnecessary whitespace — safely. It tokenizes your code rather than blindly deleting characters: string literals, template literals and regular expressions pass through completely untouched, and newlines that JavaScript's automatic semicolon insertion (ASI) depends on are preserved, so the minified code behaves exactly like the original.
Unlike aggressive bundler minifiers, this tool deliberately does not rename variables or restructure logic. That makes it dependency-free and guaranteed safe for any script, at the cost of a somewhat smaller compression ratio — typically 15–35% depending on comment density.
How to Minify JavaScript
- Paste your script into the left box.
- Click Minify JavaScript.
- Review the size report, then copy the output or download
script.min.js.
What Gets Removed — and What Doesn't
- ✅ Removed:
// line comments,/* block comments */, indentation, blank lines, spaces around operators. - 🔒 Preserved: everything inside
"strings",'strings',`template literals`and/regex/literals. - 🔒 Preserved: newlines whose removal could change ASI behavior (e.g. before a line starting with
(or[). - 🔒 Preserved: variable names, function names, code structure — debugging stays feasible.
Use it for handwritten site scripts, quick fixes on legacy projects without build tooling, or to shrink inline scripts in HTML emails and landing pages.