JSON Format
Indent JSON with 2 or 4 spaces or tabs, minify it, or show it as a collapsible tree or a graph of boxes that copy any value's path; repair loose JSON, sort its keys, pick out values with a JSONPath query, flatten it to dotted paths and back, see what takes up its size, and turn an array into JSON Lines and back.
About this tool What it's for, how to use it and an example
What it's for
Make JSON readable, make it compact, or explore it as a tree or a graph. It also checks that the JSON is valid and tells you where it isn’t.
For example, when an API returns one enormous line of JSON, prettify it to read it, or use the tree to find one value deep inside a large response.
How to use it
Paste JSON, choose an indent (2 or 4 spaces, or tabs), then:
- Prettify lays it out with one value per line.
- Minify removes all unnecessary spaces and line breaks, for the smallest output.
- Tree shows it as a collapsible outline, with the size of each object and array. Use Expand all and
Collapse all to move around. Choose or tab to any value and its JSONPath (such as
$.items[2].name) shows under the buttons; Copy path, or pressing C, copies it, ready to use as a query. - Graph draws it as boxes joined by lines, left to right: each object or array is a box listing its plain values, linked to boxes for the objects and arrays inside it. Choose or tab to a box’s title or a value to see and copy its path, as in the tree. Very large JSON is drawn up to its first 400 objects and arrays.
- Array to JSON Lines turns an array into JSON Lines (also called NDJSON): each item compacted onto a line of its own, the form logs, data exports and bulk APIs use. JSON Lines to array does the reverse, skipping blank lines and naming the first line that isn’t valid JSON.
- Flatten turns nested JSON into one object of paths and values, such as
"user.tags[0]": "admin", the form translation files, environment settings and spreadsheets often want. Unflatten turns it back, and also reads theuser.tags.0form other tools write. - Size and structure reports the size as written and minified, how deeply it nests, how many values of each kind and keys it holds, the longest array and string, and which parts at the top take up the most space.
JSON that’s almost right is repaired first, and the message says what was fixed: comments, trailing commas,
single-quoted strings, keys without quotes, and Python’s True, False and None. Tick Sort keys to put
every object’s keys in alphabetical order (remembered). Type a JSONPath query such as
$.items[?(@.price < 10)].name to keep only the matching values: .name, ['name'], [0], [-1], [*],
[0:3], ..name (at any depth) and filters with ==, !=, <, <=, > and >= work.
If the JSON can’t be repaired, the error message gives the line and column of the problem.
Example
Paste this and choose Prettify:
{"name":"Alice","tags":["admin","dev"],"active":true}
The result has each key on its own line, indented by 2 spaces. Delete the last } and try again: the tool
reports the error instead.
Good to know
Repair handles the common slips, not every mistake: a missing comma or bracket is still an error. The JSONPath support covers the everyday parts of the standard, not functions such as length(). Very large numbers may lose precision, as they do in JavaScript. Flatten writes a key that isn’t a plain name (one with a dot or a space, or a number) in brackets, as ["x.y"], so that Unflatten gives back the same JSON.
Guides: Debugging a failing API call · Why won't my JSON file load?
Path: $
Built with The third-party code and data this tool uses, and their licences
This tool uses no third-party code or data of its own: its code was written for this site.
Every page also uses Montserrat (SIL Open Font License 1.1).
Everything the site uses is on Credits and licences.
Private: this tool runs in your browser. Nothing you type, paste or choose leaves this page.
Saved you a few minutes? Say thanks with a coffee.
Something wrong with this tool, or missing from it? Report a bug or suggest a feature.