JSON

Paste and read. It takes almost-JSON, points at the error and leaves your data alone. Nothing leaves your browser.

paste some JSON and it shows up here

How to format JSON online

Paste your JSON in the box on the left, drop a file on it, or click open file. The result shows up next to it, indented and with a color for each kind of value. To open or close an object or a list, use the arrow next to it, or open all and close all.

To take the result with you, use copy (with 2 spaces, 4 spaces or a tab) or copy minified, which removes the white space and puts it all on one line. On each line of the viewer, copy takes just that value and path copies its address, like order.items[0].price, ready to use in code.

How to find the error in invalid JSON

When the text is not JSON, the tool says in plain words what is wrong, with line and column, and go to the error takes the cursor to the exact spot. The most common errors:

  • A trailing comma after the last item, as in ["a", "b",].
  • A key or text without double quotes: in JSON, name: 'Ana' has to be "name": "Ana".
  • A bracket or brace that never closes: the message points at the line where it opened.
  • A number with a leading zero, like 007. If it is a code, it goes in quotes.

JSON from logs, Python or JavaScript

A lot of what you need to read is not strict JSON: an object copied from the console, a Python print with True and None, JSON escaped inside a string ("{\"event\":\"login\"}"). Instead of refusing it, the formatter fixes what is safe to fix and shows a list of notes: comments removed, single quotes changed, commas added, strings with JSON inside opened. Nothing is fixed silently.

Questions

Is my data sent to a server?
No. The formatter runs entirely in your browser, and the page itself forbids the browser from opening any connection. You can paste tokens, customer data or production logs safely.
Does the formatter change any value?
No. Big numbers like 12345678901234567890 and decimals like 10.50 show up exactly as they came. JavaScript's JSON.parse would round the first one and drop the zero from the second.
What is almost-JSON?
Text that looks like JSON but that JSON.parse rejects, such as JavaScript objects, Python dictionaries and config files with comments. The tool fixes what can be fixed safely and lists every fix.
Does it handle large files and JSON Lines?
Yes. Files of several megabytes open bit by bit, and several JSON values in a row (JSON Lines or NDJSON, common in logs) become a list of documents.

Made by Ronaldo Sena, a developer in Uberlândia, Brazil, who also writes about code and chess on the blog.