JSON Viewer
Explore JSON as a collapsible tree instead of a wall of text.
Everything is processed in your browser. Nothing you paste is uploaded or stored.
In-depth guide
Reading JSON as a tree: what the viewer shows and what it hides
How the viewer turns parsed JSON into a collapsible tree, how arrays, empty containers, strings and numbers are displayed, and where the display differs from your source text.
Key figures at a glance
- Source of the tree
- The value returned by the browser's JSON.parse
- Not your original text, so key order and number spelling can differ from what you pasted.
- Node labels
- {n} for an object with n keys, [n] for an array with n items
- Empty containers show {0} and [0].
- Array positions
- Shown as 0, 1, 2 … (zero-based)
- These are indexes, not keys in your data.
- Initial state
- Everything expanded
- Expand all and Collapse all toggle every node at once.
What you see
Paste JSON on the left and the right-hand pane shows it as a tree. Every object and array is a native HTML disclosure widget: click its summary line to fold or unfold. The summary shows the key, then a count in braces for objects (n: {3}) or in square brackets for arrays (tags: [2]). Scalar values appear on one line as key: value.
Everything starts expanded. Expand all and Collapse all open or close every node. Editing the text rebuilds the tree from scratch, so fold state is not remembered between edits. The viewer is read-only: it has no search, no path copy and no editing, and there is no output box or download.
Invalid input empties the tree and shows Invalid JSON: … under the boxes, with a line and column when the browser supplies a position. Empty input clears the tree silently.
Worked example
Pasting {"name":"Mei","tags":["a","b"],"n":{"x":1.50,"y":[],"z":{}},"ok":true,"v":null,"1":"one"} produces this tree (captured from the real page; nesting is shown by indentation in the pane):
{6}
1: "one"
name: "Mei"
tags: [2]
0: "a"
1: "b"
n: {3}
x: 1.5
y: [0]
z: {0}
ok: true
v: null
Three things to notice. The key "1" appears first although it was last in the text. 1.50 is shown as 1.5. Array items are labelled 0 and 1, which are positions rather than data.
Why the tree can differ from your text
- Key order: JavaScript objects list integer-like keys first, ascending, then other keys in insertion order. IDs used as keys (
"10","2") therefore appear as2,10, before names. - Duplicate keys: only the last value survives, so a repeated key silently disappears from the tree. RFC 8259 says duplicate names make behaviour unpredictable.
- Numbers: values are shown with JavaScript's number formatting.
12345678901234567890is displayed as12345678901234567000,1e2as100, and1e400asInfinity(the parser overflows it). - Strings: displayed inside double quotes but not escaped.
"a\"b"shows as"a"b", a\ninside a string shows as ordinary whitespace and a tab shows as a gap. Do not copy values from the tree when exact escaping matters. - Types: strings, numbers, booleans and
nulluse different colours, but without colour only the quote marks distinguish"1"from1.
Navigating large documents
The tree is built eagerly: every node becomes an HTML element, even those you collapse afterwards, and there is no virtualisation. Very large documents can therefore make the tab slow or unresponsive. For big files, extract the relevant part first, or use JSON to text to turn the structure into greppable path = value lines. In a deep document, Collapse all and then open one branch at a time.
Tip: The counts in the summaries are a quick sanity check. If an API should return 50 items and the array says
[49], investigate before you read any further.
Common mistakes
- Reading
0,1,2under an array as keys of the data. They are only positions. - Trusting the tree for exact numbers or key order of the source.
- Pasting several JSON documents at once (JSON Lines); the parser rejects everything after the first.
- Expecting the tree to survive an edit: the fold state resets whenever the text changes.
Related tools
Check syntax with the JSON validator, re-indent with the JSON formatter, flatten paths with JSON to text, or turn arrays of objects into rows with JSON to CSV.
Frequently asked questions
How do I collapse part of a JSON tree?
Click any object or array to fold it, or use Collapse all and Expand all to change the whole tree at once.
Is my JSON sent to a server?
No. Everything happens in your browser. Nothing you paste is uploaded, logged or stored, which matters when the document contains keys, tokens or personal data.
Why is my JSON reported as invalid?
The most common causes are trailing commas, single quotes instead of double quotes around keys and strings, and unescaped line breaks inside a string. The error message gives the line and column of the first problem.
Does it change my data?
No. The document is parsed and re-serialised, so only whitespace changes. Key order is preserved and values are untouched.
Can it handle large documents?
Yes, within your browser's memory. Documents of a few megabytes are fine; extremely large files may make the page pause briefly while it parses.
Sources
- IETF — RFC 8259, The JSON Data Interchange Format — Object, array, string, number and literal value types.
- MDN — The Details disclosure element — The native expand and collapse behaviour the tree is built on.
This guide explains published rules in plain language. It is not financial, legal or official advice — rules change, so confirm with the agency linked above before you commit.