How to validate and format JSON
The editor validates your document as you type. Each change is parsed in the browser first and checked again on the server, so you get an answer immediately instead of waiting for a round trip. A valid document is summarised with its key count, value count, nesting depth and data types. An invalid one reports the exact line, column and the offending snippet, so you can jump straight to the problem.
- Paste JSON into the editor, drag a
.jsonfile onto it, or start from one of the built-in samples. - Read the result: a valid document shows its statistics, an invalid one shows the first syntax error.
- Explore the structure in the Tree view, or list every key and value in the Table view with its JSON path.
- Format with two spaces, four spaces or a tab, minify for transport, then copy or export the result as CSV or XML.
Documents up to 5 MB are accepted. Larger files are still parsed and summarised in the browser, but the server-side check and the exports are skipped to keep the page responsive.
Common JSON syntax errors
JSON is deliberately strict. A document that looks fine in JavaScript can still be rejected by a JSON parser, and a single stray character is enough to invalidate the whole file. These are the mistakes the validator catches most often.
| Problem | Invalid | Valid |
|---|---|---|
| Trailing comma | {"a": 1,} | {"a": 1} |
| Single quotes | {'a': 'b'} | {"a": "b"} |
| Unquoted key | {a: 1} | {"a": 1} |
| Comment | {"a": 1} // note | {"a": 1} |
| Missing comma | {"a": 1 "b": 2} | {"a": 1, "b": 2} |
| Raw line break in a string | "line1 line2" |
"line1\nline2" |
| Non-finite number | {"n": NaN} | {"n": null} |
| Leading zero | {"n": 01} | {"n": 1} |
The viewer always reports the first error it finds. Fix it and run the check again to surface the next one — that is usually faster than hunting for every problem at once.
What is a JSON path?
A JSON path is a compact address that points to one value inside a document. The root
is written $, object members are joined with a dot, and array items use a
zero-based index in square brackets. For the sample document above,
$.store.book[0].title resolves to the title of the first book.
Keys that contain a space, a dash or a leading digit use bracket notation instead, for
example $['first-name']. Click any row in the tree or the table to see its
path and copy it in one click.
The same notation works with JSONPath libraries. In jq the leading
$ is dropped and the path becomes
.store.book[0].title, which is handy when you want to query a large
response on the command line.
When should you export JSON as CSV or XML?
JSON is the natural format for APIs, but spreadsheets and older enterprise systems expect a flatter shape. Converting is often the quickest way to move data between them.
- CSV is best for an array of records with the same keys. Each record becomes a row, and each JSON path becomes a column that opens directly in Excel, Google Sheets or a database import.
- XML is useful when the receiving system speaks SOAP or expects a legacy schema. Arrays become repeated elements and nested objects keep their hierarchy.
- Nested values are flattened with dot paths, so
$.user.address.citybecomes its own column or element instead of a nested object.
Exports are generated on the server from the document you pasted, and nothing is stored after the response is sent.
JSON vs. JSON5 vs. JavaScript objects
JSON5 relaxes the syntax for hand-written configuration files, which is why it is
common in build tooling. APIs and anything consumed by JSON.parse must
stay strict JSON, which is what this validator checks.
| Feature | JSON | JSON5 |
|---|---|---|
| Comments | Not allowed | Allowed |
| Trailing commas | Not allowed | Allowed |
| Unquoted keys | Not allowed | Allowed |
| Single-quoted strings | Not allowed | Allowed |
Accepted by JSON.parse | Yes | No |
Is it safe to paste sensitive JSON?
The tree, the table and the search all run in your browser, so the document is rendered instantly and is not sent anywhere for those features. The server is only involved when it double-checks the syntax or builds a CSV or XML export, and it does not store the payload. As with any online tool, redact passwords, tokens and personal data before pasting production data.