Skip to content

JavaScript Minifier

Strip comments and whitespace from your JS code for smaller, faster-loading scripts

0 characters

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.

$ faq

What does JavaScript minification do?
It removes comments (both // and /* */), collapses whitespace and newlines, and strips characters that are not needed for execution. The result is functionally identical code in fewer bytes — faster to download and parse.
Does this rename variables?
No. This is a whitespace-and-comment minifier, not a mangler. Variable names, function names, and identifiers are kept as-is. For variable renaming (mangling), use build tools like Terser, esbuild, or the Closure Compiler.
Can minification break my code?
The minifier preserves all string literals, template literals, and regex patterns. It only removes whitespace where JavaScript allows it. In very rare cases, code that relies on Automatic Semicolon Insertion (ASI) in unusual ways might behave differently — always test minified code before deploying.
How much smaller does JavaScript get?
Comment-and-whitespace removal typically saves 20–40%. With variable mangling (not done by this tool), savings can reach 50–70%. The actual reduction depends on how heavily commented and formatted the source is.
Should I minify before or after bundling?
After. Bundle first (with Webpack, Rollup, or esbuild), then minify the output. Minifying individual files before bundling can make debugging harder and provides no additional size benefit.
Does it handle ES6+ syntax?
Yes. The minifier handles template literals (backticks), arrow functions, const/let, destructuring, and other modern syntax. It processes the code as text and does not transform or transpile it.
Is my code sent to a server?
No. All processing runs in client-side JavaScript. Nothing is uploaded or stored.