How to use it

  1. Paste your JSON in the top box. The result updates as you type.
  2. Pick a layout: 2 spaces, 4 spaces, tabs, or minify.
  3. Tick Sort keys A to Z to put the keys of every object in order.
  4. To get a spreadsheet file, set Show the result as to CSV.
  5. Press Copy result.

Your JSON stays in your browser. Nothing is uploaded, so it is fine to paste config files and API replies.

Finding an error

When the JSON is not valid, the tool shows the line and the column of the first problem. It shows the bad line with a marker under the exact spot, and it says what to fix. Fix that one and the next problem shows, if there is one.

These are the mistakes people make most:

  • A comma after the last item. [1, 2,] is not valid. Remove the last comma.
  • Single quotes. JSON only takes double quotes around text and names.
  • Names without quotes. Write {"name": 1}, not {name: 1}.
  • Comments. JSON has no comments. Remove lines that start with //.
  • Wrong words. Use true, false and null in lower case.
  • Backslashes in Windows paths. Write C:\\Temp with two backslashes.

Format or minify?

Formatted JSON puts each value on its own line with indents. Use it to read a file, compare two versions, or keep a config file in source control. Minified JSON removes every space and line break. Use it to send data over a network or to paste JSON into a one-line setting. Both forms hold the same data.

What the counts mean

  • Keys is the number of names in all objects, at every level.
  • Depth is how many levels of objects and arrays sit inside each other.
  • Size is the size in bytes when saved as UTF-8, for your input and for the result.

JSON to CSV

CSV needs rows, so the JSON must be an array of objects. Each object becomes one row. The columns are all the names found in any object. A missing value leaves an empty cell. A value that is itself a list or an object is written as JSON text in its cell. Open the CSV in Excel, or load it in PowerShell with Import-Csv.

Format JSON without this page

In PowerShell, run Get-Content data.json -Raw | ConvertFrom-Json | ConvertTo-Json -Depth 20. Set -Depth high enough, or PowerShell cuts off the deeper levels.

Questions

Does sorting the keys change my data?

No. The order of names in a JSON object has no meaning, so a program reads the same data. Sorting makes two files easier to compare. The order of items in arrays does matter, and the tool leaves arrays as they are.

How large can the JSON be?

A file of about 1 MB works well. The tool waits until you stop typing before it runs again, so the page stays usable. Much larger files work too, but each change takes longer.

Why does my JSON fail here when my JavaScript code accepts it?

JavaScript object syntax allows more than JSON does: single quotes, names without quotes, comments and a comma after the last item. This tool checks strict JSON, which is what APIs and most config readers need.