JavaScript Formatter
Format minified JavaScript with indentation and line breaks at semicolons and braces.
How to use this tool
- 1
Paste or type your JavaScript into the input textarea.
- 2
Watch the indented version appear live in the output box below as you type — there is no Format button.
- 3
Select the formatted text in the output box and copy it with your keyboard (there is no copy button).
- 4
Scan the result for any line that split inside a string, regex, or comment, and fix those by hand if needed.
How does this JavaScript formatter actually work?
This is a lightweight re-indenter, not a real parser. It walks your code one character at a time and applies a few fixed rules: it adds a newline and increases indentation after every opening brace or bracket, decreases indentation before a closing one, breaks the line after every semicolon, and breaks after a comma only when the previous character was a closing brace or bracket (the gap between object or array elements). Indentation is hard-coded to two spaces and cannot be changed, and braces and square brackets are treated identically. Because it has no tokenizer, it cannot tell code from text. Any brace, bracket, semicolon, or comma that lives inside a string, template literal, regular expression, or comment is treated as structural, so a line like const s = 'a;b' will wrongly split at the semicolon inside the string. It also only breaks at literal semicolons, so it does not honor automatic semicolon insertion: semicolon-free code stays on one line. Treat it as a quick visual aid for eyeballing minified or one-line snippets, not as a correctness-preserving tool. For real reformatting that understands syntax, keeps comments, and never corrupts strings, use Prettier or your editor's built-in formatter.
Common use cases
Eyeballing a minified vendor bundle or one-line snippet to see its rough structure before debugging.
Quickly indenting a short config or object literal you pasted from a chat message or log line.
Spreading a dense JSON-like object across multiple lines so nesting becomes visible.
Teaching or demoing how braces and semicolons map to indentation levels for beginners.
Making a compressed third-party script readable enough to locate a specific function or variable.
Sanity-checking that brackets are balanced, since unbalanced input leaves the indentation visibly skewed.
Frequently asked questions
Is this as good as Prettier?▼
Why did my code break inside a string or comment?▼
Can I change the indentation size or style?▼
Will it add missing semicolons or fix my syntax?▼
Why didn't a list like [1, 2, 3] break onto separate lines?▼
Does this upload my code anywhere?▼
Related tools
JWT Decoder
Decode JSON Web Tokens (JWT) instantly — inspect the header, payload, and signature claims. Runs entirely in your browser; tokens never leave your device. Safe for production secrets.
JSON Formatter & Validator
Format, validate, and minify JSON instantly. Catches syntax errors with line numbers, pretty-prints with adjustable indent, supports large payloads. Runs in your browser — no upload.
XML Formatter & Beautifier
Format and beautify XML documents — proper indentation, line breaks, namespace handling. Useful for SOAP responses, sitemaps, RSS feeds, and Android resource files.
Base64 Encoder & Decoder
Encode and decode Base64 strings.
URL Encoder & Decoder
Encode/decode URL-safe strings.
HTML Entity Encoder & Decoder
Convert special characters to/from HTML entities.