JavaScript Minifier: Minify JavaScript Source
Identifier-safe JavaScript minify in this browser. Comments and insignificant whitespace are stripped. String literals, regular-expression literals, and template literals โ including nested ${} interpolations โ are copied unchanged. Line breaks that trigger automatic semicolon insertion stay meaningful. Identifiers are not renamed. This is not Terser, UglifyJS, Closure Compiler, esbuild, or SWC. Source is never passed to eval or new Function.
Drop a .js, .mjs, .cjs, or .txt file here. Client-only FileReader. Nothing is uploaded.
Output is assigned as plain text. Input is never executed.
What this minifier does โ and does not do
This tool walks the source as a lexer. It removes line comments, block comments, hashbang comments, and whitespace that is not required to keep adjacent tokens separate. It is an honest Closure Compiler WHITESPACE_ONLY / esbuild minifyWhitespace subset: identifiers stay as written.
- Strings (
',"), templates (backticks and${}), and regex literals keep every character, including spaces and comment-like text inside them. - A space is inserted only when two tokens would otherwise merge (for example
return 0,a+ +b,1 .toString()). - A semicolon is inserted when a removed line break would have triggered automatic semicolon insertion after
return,throw,break,continue,yield,using, postfix++/--, orasyncbeforefunctionor(. - It does not mangle names, fold constants, drop dead code, rewrite syntax, or parse TypeScript or JSX.
- It does not run the program. Unterminated strings, templates, comments, or regex literals are reported. Other syntax errors may still minify because there is no full parser.
- Slash after
}uses a brace-context heuristic. Rare object-literal vs. block-body cases can mis-read/as regex or division.