JavaScript Minifier & Beautifier
Compress JavaScript or expand a minified file back into readable code — deliberately conservative, so the result always behaves exactly like what you pasted in.
Only whitespace and comments are ever changed. No JavaScript token is renamed, reordered or removed, so the output cannot behave differently from your input. That also means the size reduction is smaller than tools which rewrite your code — no variable mangling, no dead-code removal — no merged selectors, no collapsed shorthands — and because SQL needs whitespace between tokens, it can only be collapsed, never removed. This formats your source; it does not compile it. Your types are preserved, not stripped.
/*! banner comment is always kept, the usual
convention for a licence header.
Drop a JavaScript file here
Up to 4 MB · nothing uploaded
{{ error }}
{{ commentWarning }}
Verified — every token preserved
The output was re-tokenized and compared against the input: all {{ tokenCount }} code tokens are identical, in the same order. Only whitespace and comments differ.
Output rejected
The result did not survive the token check, so it was discarded rather than shown to you. This is a bug in the tool, not in your code — please treat the input as unformatted.
Your JavaScript is tokenized and reformatted entirely in your browser. Nothing you paste or drop is ever uploaded to a server.
Deliberately conservative, and why that is the point
This minifier removes comments and unnecessary whitespace. It does not rename a single variable, remove a single unreachable branch, or rewrite a single expression. Those are exactly the transforms that give Terser and UglifyJS their much larger savings — and exactly the transforms that can change behaviour if they misread your code. The result here is a bigger file that is guaranteed to do the same thing.
Automatic semicolon insertion is treated as a hard constraint
JavaScript sometimes treats a line break as the end of a statement. That means joining two
lines can silently change which statement a leading (, [,
`, + or - belongs to — and a return followed
by a newline returns undefined regardless of what is on the next line. Wherever
removing a newline could change that reading, the newline stays. It costs a few bytes and
removes an entire category of subtle breakage.
Regular expressions, template literals and division
A forward slash in JavaScript can start a regular expression or mean division, and telling them
apart requires looking at what came before it. This tool does that, and adds a safety net: a
regex that does not close on its own line is treated as division instead, so a stray slash can
never swallow the rest of your file. Template literals, including nested
${…} interpolations, are preserved character for character.
Beautifying a minified library
Re-indenting works fine, but no tool can bring back original variable names — a minifier that
renamed userAccountId to a destroyed that information permanently.
Expect readable structure, not the original source.
Frequently asked questions
Is it safe to minify JavaScript here?
Yes, and it is deliberately conservative to stay that way. Only whitespace and comments are changed. Variables are never renamed, dead code is never removed, and expressions are never rewritten, so there is no transform that could alter behaviour. The trade is a smaller size reduction than a tool that does all of those things.
How is this different from Terser or UglifyJS?
Those are optimising compilers: they shorten identifiers, fold constants, drop unreachable branches and restructure code. That is where most of their compression comes from, and also where any bug in them would change what your code does. This tool only strips formatting, so it compresses less and cannot change behaviour.
What is automatic semicolon insertion, and why does it matter here?
JavaScript treats some line breaks as statement ends. Joining two lines can therefore change which statement a leading bracket, parenthesis, backtick, plus or minus belongs to. Where removing a newline could do that, this tool keeps the newline instead — a few bytes larger, and correct.
Does it understand regular expressions and template literals?
Yes. A forward slash is decided as either a regex literal or a division operator from the preceding token, and a regex that does not close on its own line is treated as division instead. Template literals, including nested interpolations, are kept exactly as written.
Can it beautify a minified library?
Yes — that is one of the main uses. It re-indents by brace and bracket depth and puts one statement per line. It cannot restore original variable names, because a minifier that renamed them destroyed that information; nothing can recover it.