Updated November 16, 2026 · Beginner developer tutorial
What does JSON error mean? A JSON error usually means that text expected to follow the JSON format contains invalid syntax, cannot be parsed, or does not match the structure an application expects. In JavaScript, for example, malformed JSON passed to JSON.parse() commonly produces a SyntaxError. This guide explains the message, shows nine real-world error patterns and provides practical fixes.
Quick answer: JSON errors often come from single quotes, trailing commas, missing colons, missing brackets, invalid escape sequences or incomplete data. First identify the exact error location, correct the syntax, and test again with a JSON parser or formatter.
What Is JSON, and Why Does It Show an Error?
JSON stands for JavaScript Object Notation. It is a lightweight text format used to exchange structured data between applications, including APIs, web services and configuration files. JSON supports strings, numbers, booleans, null, arrays and objects. The syntax is intentionally strict so programs can interpret the same data consistently.
{
"name": "Asha",
"active": true,
"roles": ["writer", "editor"]
}
This is valid JSON: object keys and text values use double quotes; each key is followed by a colon; properties are separated by commas. A missing character can prevent the entire object from parsing.
9 Common JSON Errors With Before-and-After Examples
1. Property names use single quotes
Invalid: {'name':'Asha'}. Standard JSON requires double quotes around property names and string values.
Fixed: {"name":"Asha"}. This commonly explains a message such as “expected property name” or “property names must be double-quoted strings.”
2. Trailing comma in an object or array
Invalid: {"name":"Asha",} or [1,2,3,]. Trailing commas are permitted in some JavaScript code, but not in standard JSON.
Fixed: {"name":"Asha"} or [1,2,3].
3. Missing comma between properties
Invalid: {"name":"Asha" "age":22}. JSON properties must be separated by commas.
Fixed: {"name":"Asha","age":22}.
4. Missing colon after a property name
Invalid: {"age" 22}. Every property must have a colon between its name and value.
Fixed: {"age":22}.
5. Unclosed bracket or brace
Invalid: {"skills":["HTML","CSS"]. The outer object has no closing brace.
Fixed: {"skills":["HTML","CSS"]}. Check nested arrays and objects from the inside out.
6. Unescaped quotation mark inside a string
Invalid: a string such as {"message":"He said "hello""} terminates early.
Fixed: escape the inner quotes, for example {"message":"He said "hello""}.
7. Invalid number format
Invalid: {"quantity":01} or {"price":4.}. JSON does not allow leading zeroes in ordinary numbers or a decimal point without following digits.
Fixed: {"quantity":1,"price":4.0}.
8. Invalid JSON keywords
Invalid: {"active":True} or {"value":undefined}. JSON keywords are lowercase true, false and null; undefined is not a JSON value.
Fixed: {"active":true,"value":null}, if null accurately represents the intended data.
9. Unexpected end of input
Invalid: {"ready":. The parser reached the end before receiving the expected value and closing brace.
Fixed: {"ready":false}, assuming that was the intended value. An incomplete network response can also cause this problem; do not insert arbitrary content into data you did not author.
What Does “Unexpected Token” Mean in JSON?
“Unexpected token” means a parser encountered a character or token that was not allowed at the current position. The exact wording depends on the browser, runtime and parser version. Examples include a single quote where a double quote was expected, an extra comma before a closing bracket, or HTML returned where JSON was expected.
For example, if an API is supposed to return JSON but returns a webpage beginning with <!doctype html>, JSON.parse() may fail on the first character. In that case, the problem could be the HTTP response, an authentication redirect or a server error—not merely a misplaced comma.
How to Fix a JSON Parse Error Step by Step
- Capture the actual input: inspect the raw JSON text or API response rather than guessing what was returned.
- Read the parser message: note the position, line and column when provided.
- Inspect surrounding characters: check quotes, separators and matching brackets near the reported location.
- Format the JSON: indentation can reveal mismatched nesting more clearly.
- Correct one issue at a time: errors later in a document may be consequences of an earlier mistake.
- Validate again: use
JSON.parse()or a trustworthy validator, then test the application with the corrected data.
Use a formatter to inspect structured data
The PerkAbility Rewards JSON Formatter is a convenient starting point for inspecting JSON text. A formatter helps make nested objects readable; do not assume any formatting tool can automatically repair every invalid payload. For more examples, see our existing complete guide to fixing JSON syntax errors.
JSON.parse Error vs API Error: What’s the Difference?
| Issue | Typical symptom | Where to investigate |
|---|---|---|
| JSON syntax error | Parser rejects punctuation or data format | Raw payload, quotes, commas, braces |
| HTTP/API error | Server returns 401, 404, 500 or HTML | Network status, response headers, authorization |
| Schema mismatch | JSON parses but required fields are absent | API contract and field validation |
| Wrong value type | Program expects a number but receives text | Application logic and data types |
A successful parse only establishes syntactic validity. It does not prove the data is semantically correct, safe to trust or compatible with your app.
Practical JavaScript Example: Handle Bad JSON Safely
const input = '{"name":"Asha","active":true}';
try {
const data = JSON.parse(input);
console.log(data.name);
} catch (error) {
console.error("Invalid JSON:", error.message);
}
In production systems, also check network response status and expected content type before parsing remote responses. Avoid displaying internal stack traces or sensitive payloads to website visitors.
Frequently Asked Questions About JSON Errors
What does JSON error mean on a website?
It often means the site or app could not interpret JSON it expected to receive. The underlying cause may be invalid syntax, an incomplete response or an unexpected data structure.
How do I find the JSON error at position 1?
Inspect the opening characters of the raw input. For example, a property name enclosed in single quotes can trigger an error near the start. Parser messages vary by environment.
Can a JSON formatter fix broken JSON automatically?
Not necessarily. Formatters can make valid JSON easier to read; invalid JSON may need manual corrections or a dedicated repair tool.
Is a JSON syntax error the same as a server error?
No. One concerns parsing the returned data; the other concerns the network or application response. A server error can indirectly cause a JSON parse failure.
What does “unexpected end of JSON input” mean?
The parser reached the end of the text before it received a complete JSON value. Look for truncated data, unfinished strings, or unclosed arrays or objects.
Sources
Educational content; error messages depend on the runtime and language version. Do not paste confidential production data into third-party tools without reviewing their privacy and handling policies.
