7 JSON Errors That Break APIs—and How to Fix Each One
A practical debugging guide with broken examples, corrected JSON and a checklist you can reuse when an API, config file or import refuses to parse.
First: JSON is not a JavaScript object literal
JSON looks similar to JavaScript object syntax, but the rules are narrower. A JSON value may be an object, array, number,
string, true, false or null. Object names are strings, so they need double quotation marks.
Comments, functions, undefined and trailing commas are not part of standard JSON.
That distinction matters when copying a JavaScript configuration object into an API request. Code that runs perfectly inside
a JavaScript file may still be invalid when sent as application/json.
Seven common JSON errors
1. Single quotes instead of double quotes
{'name':'Mina','active':true}{"name":"Mina","active":true}JSON strings and property names use double quotes. Replacing every single quote blindly can damage apostrophes inside values, so correct the syntax with care.
2. A missing comma between members
{
"name": "Mina"
"active": true
}{
"name": "Mina",
"active": true
}A comma separates one object member from the next. Error positions often appear just after the real mistake because the parser only knows something is wrong when it reaches the following token.
3. A trailing comma
{
"items": ["red", "blue"],
}{
"items": ["red", "blue"]
}JavaScript sometimes permits trailing commas, but standard JSON does not. Check the last item in every object and array.
4. An unquoted property name
{status: "ready"}{"status": "ready"}Even a simple property name needs double quotes. This is one of the most common signs that a JavaScript object literal was pasted where JSON was expected.
5. Mismatched brackets or braces
{"items": [1, 2, 3}{"items": [1, 2, 3]}Objects open and close with braces; arrays use square brackets. Formatting the surrounding section makes an unmatched closing character easier to spot.
6. An invalid escape or an unescaped quote
{"message": "She said "hello""}{"message": "She said \"hello\""}A quotation mark inside a JSON string must be escaped with a backslash. Backslashes used in Windows paths also need escaping, for example "C:\\Users\\Mina".
7. Duplicate property names
{
"status": "draft",
"status": "published"
}
Some parsers accept duplicate names and keep only one value, so this may not produce a syntax error. It is still dangerous: different software can handle duplicates differently. RFC 8259 says object names should be unique for interoperable behaviour. Rename the fields or combine the values into an array when both matter.
A repeatable debugging checklist
- Read the first parser error. Later errors may be side effects of the first broken token.
- Inspect the previous line. A missing comma or quote often becomes visible one line before the reported position.
- Format the smallest valid section. Large documents are easier to debug when you isolate one object or array.
- Compare opening and closing characters. Count braces, brackets and quotation marks around the failing area.
- Check the data contract separately. Syntax can be valid while a required field, type or value is still wrong for the receiving system.
- Test again with non-sensitive data. Never paste live API keys, access tokens, passwords or customer records into a tool you have not assessed.
Formatting, syntax validation and schema validation are different
| Check | What it answers | What it cannot prove |
|---|---|---|
| Formatting | Can the structure be displayed with readable indentation? | That required fields or correct values are present. |
| Syntax validation | Does the text follow JSON grammar? | That the receiving API accepts the document. |
| Schema validation | Does the data match declared fields, types and constraints? | That every business rule or downstream process succeeds. |
ToolNoova's JSON Formatter performs parsing, readable formatting and minification in your browser. It is useful for the first two checks, but it is not a JSON Schema validator and does not know the private requirements of your API.