JavaScript Minifier
Remove comments and insignificant whitespace from JavaScript with a tokenizer that respects strings, template literals, and regex.
Processed locally in your browser — nothing is uploaded.
JavaScript Minifier
0 characters
Whitespace-level only: comments and insignificant spacing are removed, but nothing is renamed or rewritten, and line breaks that automatic semicolon insertion depends on are kept.
Minified JavaScript
Output appears here…About JavaScript Minifier
A safety-first whitespace minifier. A real tokenizer walks the source, so strings, template literals (including nested ${} expressions), regular expression literals, and comments are each recognised for what they are and never corrupted.
Line breaks that automatic semicolon insertion depends on are preserved — a newline is only dropped where it provably cannot change how the code parses. That costs a few bytes compared with an aggressive compressor and buys you output you can paste without re-testing.
Common uses
- Strip comments from a snippet before pasting it into a bookmarklet or inline script
- Shrink a small standalone script on a site with no bundler
- See a dependency-free file with its documentation removed
Example
Input
// greet
function hi(name) {
return `Hello, ${name}`;
}Output
function hi(name){return `Hello, ${name}`;}Limitations
- Whitespace-level only — this is not a compressor: no variable renaming, dead-code removal, or expression rewriting
- Savings are far smaller than a real minifier's; use a build-step tool for production bundles
Frequently asked questions
Can minifying JavaScript break my code?
This minifier is built not to: a real tokenizer recognises strings, template literals, regex literals, and comments, and it never renames or rewrites anything. Line breaks that automatic semicolon insertion depends on are kept, so code that relied on ASI still parses the same way.
Is my JavaScript source code sent anywhere when I minify it?
No. Everything runs in your browser's own JavaScript engine — the source is never uploaded or stored, so proprietary code and snippets containing API keys or endpoints stay on your machine.
What is automatic semicolon insertion and why does it matter here?
ASI is the JavaScript rule that inserts a missing semicolon at certain line breaks, so 'return' followed by a newline returns undefined regardless of what the next line says. A minifier that deletes such newlines silently changes behaviour; this one only removes a line break where it provably cannot affect parsing.
Why does my minified JavaScript still contain line breaks?
Each remaining newline is one the minifier could not prove safe to remove — deleting it could trigger or suppress automatic semicolon insertion and change what the code does. This costs a few bytes compared with an aggressive compressor but means the output needs no re-testing.
How is this different from Terser or other build-step minifiers?
It only removes comments and insignificant whitespace. Terser, esbuild, and similar tools also rename variables, remove dead code, and rewrite expressions, producing much smaller output — so use one of those for production bundles, and this tool for quick jobs like bookmarklets and inline snippets.