Key takeaways
- JSON is stricter than JavaScript: double quotes only, no trailing commas, no comments.
- Keys must be strings in double quotes; values can only be strings, numbers, true, false, null, objects and arrays.
- NaN, Infinity, undefined and leading zeros are not valid JSON numbers or values.
- A validator shows the line and column of the first error; fix it and validate again.
Find the error first
Paste the text into the JSON formatter and validator. If it is invalid, you get the line and column of the first problem. Parsers stop at the first error, so fix it and validate again until the document is clean. Everything runs in your browser, which matters when the JSON contains API keys or customer data.
The common errors
1. Trailing commas
{"a": 1, "b": 2,} is invalid. Remove the comma after the last item in every object and array: {"a": 1, "b": 2}.
2. Single quotes
{'name': 'Sara'} is valid JavaScript but not JSON. Use double quotes: {"name": "Sara"}.
3. Unquoted keys
{name: "Sara"} must be {"name": "Sara"}.
4. Comments
JSON has no comments, so // … and /* … */ cause errors. Remove them, or move notes into a field such as "_comment". (Some configuration formats, such as JSONC, allow comments, but standard parsers reject them.)
5. Invalid values
undefined, NaN and Infinity are not allowed. Use null or a string instead.
6. Numbers written the wrong way
Leading zeros (007), a leading plus sign (+5), hexadecimal (0x1F) and a trailing decimal point (5.) are all invalid. Write 7, 5, 31 and 5.0. Store phone numbers and IDs as strings to keep leading zeros.
7. Unescaped characters in strings
A real line break or tab inside a string is not allowed; write \n and \t. Double quotes and backslashes inside strings must be escaped as \" and \\, which trips up Windows paths: "C:\\Users\\Sara".
8. Missing or extra brackets
Every { and [ needs a matching closing bracket. Formatting the JSON with indentation makes a missing bracket easy to spot.
9. Hidden characters from copy and paste
Text copied from documents or chat apps may contain "smart" curly quotes (“ ”) or invisible characters. Retype the quotes, or paste into a plain-text editor first. The JSON standard also says a byte order mark should not be added at the start of a JSON text.
Errors that are valid but risky
- Duplicate keys are not forbidden, but parsers handle them differently (most keep the last one). Make keys unique.
- Very large integers, above 9,007,199,254,740,991, lose precision in JavaScript. Send big IDs as strings.
Related tools
Convert spreadsheets to JSON with the CSV to JSON converter, and decode Base64-encoded payloads with the Base64 decoder before validating them.
Sources
- RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Formatrfc-editor.org
- JSON.org: Introducing JSONjson.org
- MDN: JSON.parse()developer.mozilla.org