JSON is the common text format for data in web apps and APIs. It is simple, but one wrong character makes a whole file fail to load. This guide covers what valid JSON looks like and the errors that cause most problems.
What valid JSON looks like
- Data is in objects (curly braces, with “key”: value pairs) and arrays (square brackets).
- Keys and text values use double quotes.
- Values can be text, numbers, true, false, null, objects or arrays.
- Items are separated by commas.
The most common errors
- Trailing comma. A comma after the last item is not allowed.
- Single quotes. Only double quotes are valid.
- Unquoted keys. Keys must be in quotes, unlike in JavaScript objects.
- Missing comma between two items, or a missing closing bracket.
- Comments. JSON has no comment syntax.
- Special values. NaN, undefined and Infinity are not valid.
- Unescaped characters such as a raw new line or a quote inside text.
How to fix it
Paste the data into the JSON Formatter. It indents the data so the structure is easy to read and reports an error if the text is not valid, which points you toward the place to fix. Fix the first error, then check again, because one missing bracket can cause several messages. You can also minify the JSON to make it smaller before sending it.
Converting JSON to a spreadsheet or PDF
An array of similar objects maps neatly to rows and columns. The JSON to CSV Converter turns it into a table you can open in a spreadsheet, and converts CSV back to JSON. For a printable copy, use JSON to PDF. Deeply nested data does not fit a flat table well, so check the result.
Dates and timestamps in JSON
JSON has no date type, so dates appear as text or as a Unix timestamp, the number of seconds since 1 January 1970 UTC. For example, 1700000000 is 14 November 2023, 22:13:20 UTC. Convert them with the Unix Timestamp Converter. Check whether a value is in seconds or milliseconds, since milliseconds have three more digits.
Privacy
The tools run in your browser, so what you paste is not sent to our servers. Even so, avoid pasting live passwords, tokens or private keys into any online tool, and remove them from samples first. Other helpers: Text Diff to compare two versions and UUID Generator for test IDs.