JSON Formatter and Beautifier
Re-indent minified or messy JSON with 2-space or 4-space indentation, catch syntax errors with exact line and column numbers, then copy or download the result.
API responses arrive as one unbroken line, and JSON copied out of logs has usually lost whatever indentation it had, so checking field nesting by eye is close to hopeless. This formatter re-parses the text and writes it back out with a fixed indent, aligning every nesting level, while the tree view beside it shows the same hierarchy as a structure. Invalid syntax never fails silently: you get the line number, the column, and the offending line.
Everything here is computed locally by JavaScript in the browser. The JSON you paste is not sent to a server, not proxied, and not written to a log or cache — which is what makes it usable for internal API payloads, config files and sample data carrying real business fields. The page also works with the network disconnected, since no part of the formatting depends on a backend call.
Indentation options and what re-serializing changes
The toolbar offers 2-space and 4-space indent buttons, and the formatting engine itself also accepts tab indentation. One thing worth understanding: formatting is not whitespace substitution. The tool parses the text with JSON.parse and serializes it again with a fixed indent, so every value in the output is a strictly conformant JSON value. That rebuild has side effects you should know about. Numbers are normalized: 1.0 becomes 1, 1e3 becomes 1000, -0 becomes 0. Escapes such as \u00e9 are decoded back to the character they denote. And when the same key appears twice inside one object, only the last occurrence survives. Key order is taken from the source document and preserved; the formatter does not reorder fields.
How syntax errors are located
Validation is live: every keystroke or paste re-parses the document, and the status bar flips between valid JSON and a syntax error as you type. The error message carries the parser reason, the line and column where parsing stopped, and the offending line with leading and trailing whitespace trimmed, so you can jump straight to it in a large file. Line and column are derived from the character offset the parser reports; the column counts characters, not bytes, so on a line that mixes ASCII with multi-byte characters the reported column will differ from a figure computed on UTF-8 bytes. Four mistakes account for most failures in practice: a missing or extra comma, single-quoted strings, a key without double quotes, and a trailing comma after the last member.
Split view and output actions
The view has a split mode with the editable input on the left, and a full-width single-pane mode. In split mode the right pane toggles between syntax-highlighted code, for checking the exact output text, and a tree view for expanding, searching and copying individual nodes. Toolbar actions such as minify, escape and sort keys rewrite the left pane in place, and the result stays editable afterwards. Output can be copied, downloaded as a .json file with a timestamped name, or left alone; input can be pasted or imported from local .json, .txt, .js and .ts files. The status bar keeps a running count of characters, lines, UTF-8 byte size, total keys and maximum nesting depth.
Frequently asked questions
- Does formatting make the file bigger?
- Yes. Two-space indentation typically inflates a document by 10 to 30 percent, and more as nesting gets deeper, because those spaces are pure readability cost. JSON semantics are determined entirely by the structure — line breaks and indentation do not affect the parsed result. Send the minified single-line version over the wire and keep the formatted version for reading and debugging.
- Will formatting reorder my fields?
- No. The tool re-serializes in the original key order, so the field sequence stays as it was. There are two exceptions to be aware of: numeric notation is normalized (1.0 becomes 1, 1e3 becomes 1000), and duplicate keys inside one object collapse to the last occurrence, because JSON.parse overwrites the earlier value with the later one.
- Why wasn't my non-ASCII text converted to \uXXXX?
- Standard JSON allows non-ASCII characters directly inside strings, so escaping them is unnecessary — the formatter writes them as literal characters. If a downstream system accepts ASCII only, format first and then run the text through the Unicode escape tool, which produces the \uXXXX form deliberately.
- How large a JSON file can it handle?
- There is no hard limit; it depends on browser memory and how fast the editor can render. A few megabytes usually opens fine, but beyond roughly a hundred thousand lines the syntax highlighting and the tree view slow down noticeably. At that size, switch to the full-width single pane, keep the tree collapsed, or split the data along a natural boundary and work through it in pieces.