JavaScript & Browser
JavaScript Formatter
Paste JavaScript to beautify it with clean indentation or compact it for sharing. Comments, strings, template literals and regular expressions are preserved — and your code never leaves the page.
Options
liveJavaScript input
paste or typeTokenised locally in this tab. Unterminated strings, comments, regexes and unbalanced brackets are reported with a line and column.
Formatted output
live
Common causes: an unterminated string or comment, an unbalanced
{ ( or [, or a regular expression that
never closes.
How it works
The formatter lexes the code into strings, template literals, regular expressions, comments, names, numbers and operators, then re-lays it out. Comments and literal contents are copied through untouched. It is a lightweight formatter rather than a full parser: it uses brace context to tell blocks from object literals, keeps line breaks that terminate a statement under automatic semicolon insertion, and reports lexical problems instead of failing silently. Everything runs locally and nothing is uploaded.