Shrink JavaScript Files for Production
JavaScript is typically the largest and most expensive resource a web page loads. Every kilobyte must be downloaded, parsed, compiled, and executed — all of which block interactivity. While build tools like Terser and esbuild handle minification in automated pipelines, there are many situations where you need to quickly minify a standalone script: a third-party snippet, a legacy file outside your build system, or a quick prototype you want to ship lean.
What Gets Removed
The minifier strips single-line comments (//), multi-line comments (/* ... */), leading and trailing whitespace on every line, blank lines, and redundant spaces around operators and punctuation. It preserves important comments (/*! ... */) that typically contain license notices. String literals, template literals, and regular expressions are passed through untouched.
Minification vs. Mangling
This tool performs whitespace and comment removal only. It does not rename variables (mangling), which is a more aggressive optimization that requires understanding the code's scope tree. Mangling can save an additional 30–50% but risks breaking code that uses eval, dynamic property access, or global variable names. For mangling, use Terser, the Closure Compiler, or esbuild.
Safe Handling of Strings and Regex
The minifier tracks whether it is inside a single-quoted string, double-quoted string, template literal, or regular expression, and preserves their content exactly. This prevents false removal of characters that look like comments or whitespace inside string values — a common problem with naive regex-based minifiers.
Automatic Semicolon Insertion
JavaScript inserts semicolons automatically at certain line breaks (ASI). The minifier preserves semicolons and newlines where removing them could change behavior. When collapsing lines, it ensures that statements remain properly separated. For maximum safety, the minifier inserts semicolons at line boundaries where the next line starts with a character that could be ambiguous (parenthesis, bracket, template literal).
Privacy
All processing runs in your browser. No code is sent to any server, making this safe for proprietary business logic, internal tools, and client projects.