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.

Runs in your browser v1.0.0

Options

live

JavaScript input

paste or type

Tokenised locally in this tab. Unterminated strings, comments, regexes and unbalanced brackets are reported with a line and column.

Formatted output

live


                

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.