Why this one is deliberately conservative
Serious minifiers such as Terser or esbuild rename local variables, inline functions and drop unreachable branches. They get much smaller output โ and they need a full JavaScript parser to do it safely. A browser tool that pretended to do that with pattern matching would eventually mangle a working file. So this minifier does only what can be done with certainty: it removes comments and unnecessary whitespace, and leaves every identifier exactly as you wrote it.
What it understands
The tokenizer tracks single- and double-quoted strings, template literals (including ${...} substitutions), regular expression literals, and both comment styles โ so a // inside a URL string or a /* inside a regex is left alone. It also distinguishes a division sign from the start of a regex by looking at the previous meaningful token, which is the classic trap in naive JavaScript minifiers.
Automatic semicolon insertion is respected
JavaScript sometimes ends a statement at a line break. Delete that line break and the meaning changes โ a return on its own line is the famous example. This minifier only removes a newline when the character before or after it makes an accidental statement join impossible (after an opening brace or an operator, before a closing brace, and so on). Everywhere else the newline stays. That costs a few bytes and buys you code that still runs.
Where minified JavaScript fits in a real workflow
For a small inline script, a snippet in a CMS, or a single utility file, this is all the minification you need โ and gzip on your server will handle most of the rest. For an application bundle, use a build step with esbuild, Terser or your framework's bundler: they also tree-shake and split code, which saves far more than whitespace ever will. And always keep the readable original in version control; never edit the minified copy.
Benefits
- Removes comments and whitespace without renaming a single identifier, so behaviour cannot change.
- Understands strings, template literals, regular expressions and the division-versus-regex ambiguity.
- Respects automatic semicolon insertion, keeping line breaks wherever removing one could change meaning.
- Checks that the minified result still parses as valid JavaScript before you copy it.
Limitations to know
- It does not rename variables, inline functions, drop dead code or tree-shake, so it compresses less than Terser or esbuild.
- It does not transpile modern syntax for older browsers.
- For large bundles a real build tool will always produce a much smaller file.
Common mistakes to avoid
- Confusing minification with obfuscation โ minified code is still perfectly readable once reformatted.
- Minifying a file that is already minified, which gains almost nothing.
- Committing only the minified file, leaving no readable source to maintain.
Alternatives
For stylesheets use the CSS Minifier, for markup use the HTML Minifier, and to inspect data payloads use the JSON Formatter.
Last updated: August 2026 ยท Reviewed by the AI Toolbox editorial team.
Frequently asked questions
Does it obfuscate my code?
No. Minifying is about size, not secrecy โ and this tool does not rename anything, so the logic stays perfectly readable after formatting.
Why is my saving smaller than other minifiers report?
Because they rename variables and rewrite expressions. Those need a full parser to do safely, which is out of scope for a browser tool that must never break your file.
Does it support modern syntax?
Yes โ arrow functions, classes, template literals, optional chaining and async/await all pass through untouched, because the tool never rewrites syntax.
Can I minify a whole bundle?
You can, but a build tool such as esbuild will do far better on bundles. This is for snippets and single files.