JS Minifier
Minify and beautify JavaScript online. Remove comments, whitespace, and dead code — or pretty-print minified JS back to readable form.
About this tool
This tool shrinks JavaScript by removing comments, collapsing whitespace, and trimming unnecessary semicolons (minify mode), or expands compressed JS back into indented, readable form (beautify mode). Toggle the mode with the buttons above the input — the output updates as you type.
Example — minify: function greet(name) { return 'Hello ' + name; } becomes function greet(name){return'Hello '+name}. Beautify does the reverse, restoring indentation and one statement per line.
The tokenizer understands JavaScript syntax: string and template literals, regex literals, single-line and block comments, and common operators — so comments inside strings or regexes are never accidentally stripped. The byte counter shows how much the minified output shrunk versus the input.
FAQ
How much smaller does minified JavaScript get? ›
Typically 20–50%, depending on how many comments and how much indentation the original had. Already-minified or compressed JS shrinks much less. This tool removes comments, whitespace, and trailing semicolons — structural renaming (variable shortening) and dead-code elimination require a full compiler pass.
Does the minifier change how my code runs? ›
No. Only whitespace, comments, and unnecessary semicolons (those immediately before }) are removed. All statements, operators, and identifiers stay exactly as written — no variable renaming or optimization that could alter semantics.
What about regex literals and template strings? ›
The tokenizer recognizes regex literals and template strings, so a // inside a regex or a comment-like string is never treated as a real comment. Both minify and beautify modes preserve string and regex content exactly.
Can it beautify TypeScript or JSX? ›
The beautifier focuses on JavaScript syntax — braces, semicolons, and indentation. TypeScript type annotations and JSX angle-bracket syntax may not be indented as idiomatically as a dedicated formatter would, but the output will be syntactically valid and much more readable than the compressed input.