How to read and fold a JSON document

The viewer parses the document with the strict JSON grammar and renders the result as a tree: every object and array can be folded on its own, the indentation can be set from 1 to 6 spaces per level, and keys can be shown with or without quotes.

Everything runs in the page. The document is not uploaded, the tool keeps working offline once loaded, and the input is treated as data — it is never executed as code.

  1. Paste or type the document into the box. A byte-order mark at the start and whitespace around the document are ignored, which covers files saved by editors and spreadsheet exports.
  2. Press Format JSON. Valid input renders below the box; if the syntax is broken, the tree is cleared and the bar names the line and column of the offending character.
  3. Set the indentation (1 to 6 spaces per level) and choose whether keys are shown in quotes. Both settings re-render the tree and change the text that Copy puts on the clipboard.
  4. Fold with the marker in front of any { or [, or use Expand all, Collapse all and Level 2 to Level 8. Uncheck Collapse controls to render the tree fully open, without markers.

What the viewer checks, and what it keeps

What counts as valid JSON

Input is checked against the strict JSON grammar: keys and string values take double quotes, a comma may not follow the last member of an object or array, and comments, single quotes, NaN, leading zeros and a trailing decimal point are all rejected. The reported position is the first character that does not fit the grammar.

A byte-order mark at the very beginning is skipped, and spaces, tabs and line breaks outside strings carry no meaning. The document does not have to be an object or array: a bare number, string, true, false or null renders as a single row.

What the tree keeps from the input

Numbers and escape sequences are printed the way they were written — a long integer such as 12345678901234567890 is not rounded, and \u00e9 stays an escape sequence. Copy puts the tree text on the clipboard, so the copied document differs from the source only in indentation and line breaks.

Keys are shown in quotes by default; clearing Quote keys removes them from the display and from the copied text, which is handy when members have to be pasted into JavaScript. Select All marks the same text for a manual copy, and Clear empties both the box and the tree.

Folding large documents

Every object and array carries its own marker, so parts can be closed as soon as they have been read. Level 2 to Level 8 keep the first two to eight levels open and fold everything deeper, which shows the shape of a large response at a glance.

Parsing happens entirely in the browser: the document is not uploaded, the page keeps working offline once loaded, and the input is treated as data only — it is never executed as code.

Recent tools: