Guide

Format, validate and convert JSON

When a JSON payload will not work, three questions come up in order: what does it actually say, is it valid, and what shape do I need next? This workflow answers each one with a separate tool so a failure at one step does not hide the others.

Step 1 — make it readable

Start with the JSON Formatter. Pasting a single-line payload and enabling pretty printing turns it into indented JSON you can scan. Sorting keys is optional but makes two documents easier to compare by eye, and the formatter reports a line and column if the input cannot be parsed at all.

Input

{"b":2,"a":1}

Output (2-space indent, sort keys on)

{
  "a": 1,
  "b": 2
}

Sorting applies recursively to objects and leaves array order unchanged. If you need the smallest possible payload instead, switch on Minify to get {"a":1,"b":2}.

Step 2 — find out whether it is valid

A formatter that refuses to parse is telling you the document is invalid, but not always why. The JSON Validator reports the first syntax error with a line, column and a short explanation. A trailing comma is one of the most common failures because many languages allow it and JSON does not.

Input

{
  "a": 1,
}

Output

Invalid JSON
Line 3, column 1: Trailing comma before '}' is not allowed.
Hint: Remove the comma before the closing brace.

A document with repeated keys is still valid JSON, so the validator lists the duplicate keys as warnings instead of errors; the last value is the one that survives.

Step 3 — convert to the shape you need

Once the JSON is valid, JSON to CSV flattens nested objects into dotted column names and turns arrays of objects into spreadsheet rows. The CSV to JSON tool does the reverse when a spreadsheet export is the starting point.

Output for an array of records (JSON to CSV)

id,name,email,active,joined,address.city,address.country,roles
1,Ada Lovelace,ada@example.com,true,2024-01-15,London,UK,"[""admin"",""author""]"
2,Grace Hopper,grace@example.com,false,2024-03-02,New York,USA,"[""contributor""]"
3,Alan Turing,alan@example.com,true,2024-06-10,,,[]

Nested keys become address.city, values containing commas or quotes are quoted, empty arrays become [], and missing keys become empty cells.

Common mistakes

  • Editing the pretty-printed copy and pasting it back with a trailing comma or a comment. JSON has neither.
  • Assuming a valid document has the shape you expect. Validation checks syntax, not schema; JSON Schema Validator checks the structure.
  • Converting to CSV before checking that every record has the same fields, which can shift or drop columns.