JSON Formatter & Tree Explorer

Beautify, validate and explore JSON with a collapsible tree view, two-space, four-space or tab indentation and optional key sorting.

Input
Result

About JSON Formatter & Tree Explorer

The JSON Formatter turns compact or messy JSON into clean, indented text and tells you instantly if it is broken. Pick 2 spaces, 4 spaces or tabs, and sort keys if you like.

Tree Explorer for big responses

Collapse and expand objects and arrays and search inside large API responses, so you can jump straight to the part you are debugging.

Built-in validator

Broken JSON shows an error, so you can fix a missing comma or an unclosed bracket quickly.

Common mistakes

JSON is stricter than JavaScript: keys and strings need double quotes, trailing commas and comments are not allowed.

Very long numbers

Integers above about 9 quadrillion lose precision when parsed. Keep long IDs as strings.

Only spacing changes

Formatting changes the spacing and, if you choose, the key order. Your data stays the same.

Private

Everything runs in your browser. Your code and data are not uploaded.

How to use JSON Formatter & Tree Explorer

  1. Paste your JSON or open a file.
  2. Choose the indent size and tick "Sort keys A-Z" if you need it.
  3. Press Format, or open the Tree Explorer to browse the structure.
  4. Copy the result or download it as a file.

Related guide: How to Format and Validate JSON (With Common Errors Explained)

Help & FAQ

Why does it say our JSON is invalid?

Common causes are trailing commas, single quotes instead of double quotes, unquoted keys and comments. The error message points to the position of the first problem.

Does sorting keys change the meaning?

No. JSON objects are unordered, so sorting only changes how they are displayed. Arrays keep their order.

Can it handle very large files?

, so the limit is your device memory. Files of a few megabytes are fine; very large ones may feel slow.

What are the most common JSON errors?

Trailing commas, single quotes, missing quotes around keys, and unescaped line breaks inside strings. The error message points to where parsing stopped.

Can we minify JSON as well?

Yes, use the JSON Minifier to remove spaces and line breaks.

Is it safe to paste confidential data?

Still avoid pasting live secrets on a shared computer.

Can we choose how the JSON is indented?

Yes. Pick two spaces, four spaces or tabs before formatting, and turn on key sorting if you want keys in A to Z order.

How do we find one value inside a large response?

Open the Tree Explorer, collapse the objects you do not need and search for the key or value you are after.

What is the difference between JSON and a JavaScript object?

JSON is a text format with strict rules: double-quoted keys and strings, no comments, no trailing commas and no functions. A JavaScript object literal is more relaxed and can contain code.

Can JSON contain comments?

No. Standard JSON has no comment syntax. If a configuration file allows comments, it uses a relaxed format such as JSONC or JSON5, which this formatter will report as invalid.

Why did our long number change?

Browsers store JSON numbers as 64-bit floats, so integers above 9,007,199,254,740,991 lose digits. Put very long IDs in quotes so they stay as text.

What happens if a key appears twice?

This tool keeps the last value and removes the earlier one from the formatted output, as JavaScript's parser does. Other parsers may handle duplicates differently, so check for duplicates if data seems to be missing.

What does 'Unexpected token' or 'Expected property name' mean?

The parser met a character it did not expect, often a single quote, a trailing comma or an unquoted key. The message gives the position, line and column, so look just before that point.

Can the top level be an array or a string?

Yes. A valid JSON text can be an object, an array, a string, a number, true, false or null.

Does formatting change our data?

For ordinary JSON it only adds or removes whitespace. Ticking Sort keys A-Z changes the order of keys in objects but never the order of array items. Integers beyond 9,007,199,254,740,991 and repeated keys are the exceptions.

More in Developer Tools

See all 39 in Developer Tools