Showing all 64 error patterns. Type to filter.
Error message
- Unexpected token } in JSON at position 42
- Unexpected token , in JSON
- Unexpected token { in JSON at position 0
- SyntaxError: Unexpected token
The parser found a character it didn't expect at that exact byte. Almost always a missing comma, an extra comma, or a stray bracket from copy-paste.
Tip: The position number in the error tells you the byte offset — count from the start of the document.
Error message
- Unexpected end of JSON input
- Unexpected EOF
- SyntaxError: Unterminated string in JSON
The document ended before the parser saw a closing }, ], or ". Usually a truncated paste, a missing quote, or a network response that was cut off.
Invalid
{
"name": "Ada",
"items": [1, 2, 3Valid
{
"name": "Ada",
"items": [1, 2, 3]
}Error message
- Unexpected token } in JSON at position N
- Unexpected token ] in JSON at position N
- Expecting property name enclosed in double quotes
JSON does not allow a comma after the last element. JavaScript and Python allow this, so it's an extremely common mistake when copy-pasting.
Invalid
{
"a": 1,
"b": 2,
}Tip: If you really need trailing commas, switch to JSON5 or JSONC — they're not part of strict JSON.
Error message
- Unexpected token ' in JSON at position 0
- Expecting property name enclosed in double quotes
JSON requires double quotes (") for both keys and string values. Single quotes are valid in JavaScript and Python literals, so they sneak in often.
Invalid
{ 'name': 'Ada', 'role': 'engineer' }Valid
{ "name": "Ada", "role": "engineer" }Error message
- Unexpected token n in JSON at position 2
- Expecting property name enclosed in double quotes
JSON keys must be double-quoted strings. JavaScript object literals allow bare identifiers — JSON does not.
Invalid
{ name: "Ada", role: "engineer" }Valid
{ "name": "Ada", "role": "engineer" }Error message
- Bad control character in string literal
- SyntaxError: Unterminated string in JSON
- Invalid control character
Raw line breaks, tabs, and other control characters (U+0000 to U+001F) inside a string literal are illegal — they must be escaped.
Invalid
{
"message": "line one
line two"
}Valid
{
"message": "line one\nline two"
}Tip: Use \n for newline, \t for tab, \r for carriage return, and \uXXXX for any other control character.
Error message
- Unexpected token “ in JSON at position 0
- SyntaxError: Unexpected token
Word, Google Docs, and many websites auto-replace straight quotes with curly “smart” quotes. Those are different Unicode characters and JSON parsers reject them.
Tip: Find-and-replace U+201C, U+201D, U+2018, U+2019 with straight " and ' before parsing.
Error message
- Unexpected token N in JSON at position N
- Unexpected token I in JSON at position N
- Unexpected token u in JSON at position N
JSON has no NaN, Infinity, -Infinity, or undefined. JavaScript's JSON.stringify converts NaN and Infinity to null silently — but a hand-written value will fail to parse.
Invalid
{ "ok": true, "score": NaN, "limit": Infinity, "data": undefined }Valid
{ "ok": true, "score": null, "limit": null }Tip: Use null when you mean "no value". Drop undefined fields entirely.
Error message
- Unexpected token T in JSON at position N
- Unexpected token F in JSON at position N
- Unexpected token N in JSON at position N
JSON uses lowercase true, false, and null. Python's True / False / None are different tokens and won't parse.
Invalid
{ "active": True, "deleted": False, "owner": None }Valid
{ "active": true, "deleted": false, "owner": null }Tip: If you have a Python dict as a string, use json.dumps() instead of str() to convert it.
Error message
- Unexpected number in JSON at position N
- Invalid number
JSON forbids leading zeros to avoid ambiguity with octal literals. 007 is invalid; 7 is valid.
Invalid
{ "code": 007, "version": 0123 }Valid
{ "code": 7, "version": 123 }Tip: If you need to preserve leading zeros (zip codes, IDs), use a string: "007".
Error message
- Unexpected token x in JSON at position N
JSON only allows decimal numbers. 0x1F, 0o17, 0b101 are JavaScript/Python literals — not JSON.
Invalid
{ "color": 0xFF0000, "perms": 0o755 }Valid
{ "color": 16711680, "perms": 493 }Tip: Convert to decimal first, or use a string if the original notation matters.
Error message
- (no error — but undefined behaviour)
RFC 8259 says behaviour is undefined when an object has the same key twice. Most parsers silently keep the last value, but it varies — and it's almost always a bug.
Invalid
{
"id": 1,
"name": "Ada",
"id": 2
}Valid
{
"id": 2,
"name": "Ada"
}Tip: JSON FYI's linter flags duplicate keys with both line numbers so you can pick the right one.
Error message
- Unexpected token in JSON at position 0
- Unexpected token � in JSON at position 0
Some editors and Windows tools save UTF-8 files with a leading byte-order mark (U+FEFF). Strict parsers (including Node's built-in) reject it.
Invalid
{ "name": "Ada" }Tip: Save the file as "UTF-8 without BOM" in your editor, or strip the first byte before parsing.
Error message
- Unexpected token { in JSON at position N
- Extra data: line 2 column 1
A JSON document must contain exactly one top-level value. Two objects in a row are not valid JSON — they're NDJSON, a different format.
Invalid
{ "id": 1 }
{ "id": 2 }Valid
[
{ "id": 1 },
{ "id": 2 }
]Tip: If you really want a stream of values, use NDJSON (one JSON value per line) and parse line by line.
Error message
- Unexpected end of JSON input
- Expecting value
An empty string, or a string that contains only whitespace, is not valid JSON. The smallest valid JSON document is null, true, false, a number, a string, [], or {}.
Error message
- Bad escaped character in JSON at position N
- SyntaxError: Invalid string in JSON
Only a fixed set of backslash escapes is allowed: \" \\ \/ \b \f \n \r \t and \uXXXX. Things like \x, \a, \v are JavaScript-only and will fail.
Invalid
{ "path": "C:\Users\Ada", "char": "\xFF" }Valid
{ "path": "C:\\Users\\Ada", "char": "\u00FF" }Tip: If you're embedding JSON in a JS string, you have to double-escape backslashes.
Error message
- Unexpected token . in JSON at position N
- Unexpected number in JSON at position N
- Invalid number
JSON numbers must have at least one digit on each side of the decimal point. 1. and .5 are valid in JavaScript but not in JSON.
Invalid
{ "ratio": .5, "count": 10. }Valid
{ "ratio": 0.5, "count": 10 }Tip: Use 0.5 instead of .5, and 10 or 10.0 instead of 10.
Error message
- Unexpected token + in JSON at position N
- Invalid number
JSON allows a leading minus but not a leading plus. +5 and +1.2e3 are JavaScript-friendly but rejected by every strict JSON parser.
Invalid
{ "delta": +5, "exp": 1.2e+3 }Valid
{ "delta": 5, "exp": 1.2e3 }Tip: Inside the exponent (e+3) the + is fine — it's only the leading sign of the number itself that's forbidden.
Error message
- Unexpected token n in JSON at position N
- SyntaxError: Unexpected token
JavaScript BigInts use a trailing n (e.g. 9007199254740993n). JSON has no BigInt type — it only has IEEE-754 doubles.
Invalid
{ "id": 9007199254740993n }Valid
{ "id": "9007199254740993" }Tip: Send large integers as strings to preserve precision past 2^53. Parse with BigInt() on the receiving side.
Error message
- Unexpected number in JSON at position N
- Expecting property name enclosed in double quotes
JSON object keys must be double-quoted strings — even if they look like numbers. {1: "a"} is a valid JS object but invalid JSON.
Invalid
{ 1: "first", 2: "second", true: "yes" }Valid
{ "1": "first", "2": "second", "true": "yes" }Error message
- Lone surrogate U+D800 is not a scalar value
- Invalid Unicode escape
- no low surrogate in string
Characters above U+FFFF must be encoded as a surrogate pair (\uD83D\uDE00). A high surrogate without its matching low surrogate (or vice versa) is invalid UTF-8 and strict parsers reject it.
Invalid
{ "emoji": "\uD83D" }Valid
{ "emoji": "\uD83D\uDE00" }Tip: U+D800–U+DBFF are high surrogates; U+DC00–U+DFFF are low. They must always come in pairs.
Error message
- Unexpected token c in JSON at position 0
- Unexpected identifier
A JSONP response wraps the payload in a function call like callback({...}). That's valid JavaScript but not JSON — JSON.parse will fail on the first character.
Invalid
callback({ "id": 1, "name": "Ada" });Valid
{ "id": 1, "name": "Ada" }Tip: Strip the leading identifier and trailing ); — or switch the endpoint to a plain JSON response and use CORS instead of JSONP.
Error message
- Unexpected token < in JSON at position 0
- SyntaxError: Unexpected token < in JSON
The server returned HTML (a 404 page, login redirect, or error page) and your code tried to JSON.parse it. The first character < is the start of <!DOCTYPE html> or <html>.
Invalid
<!DOCTYPE html>
<html><body>404 Not Found</body></html>
Valid
{ "error": "not_found", "status": 404 }Tip: Check response.status and response.headers.get('content-type') before parsing. Don't trust that a 200 means JSON — proxies and load balancers love returning HTML.
Error message
- (no error — silently empty)
JSON.stringify(new Map()) returns "{}" — Map and Set don't implement toJSON, so all entries are silently dropped. Not a parse error, but the resulting JSON is wrong.
Valid
{ "users": [["a", 1], ["b", 2]] }Tip: Convert with Array.from(map.entries()) or [...set] before stringifying. Or define a toJSON method on a wrapper class.
Error message
- (no error — but type is lost)
JSON has no Date type. JSON.stringify(new Date()) writes an ISO-8601 string, and JSON.parse gives you a string back — not a Date. This bites round-trips, not parsing.
Invalid
{ "createdAt": new Date() }Valid
{ "createdAt": "2026-04-26T10:00:00.000Z" }Tip: Always use ISO-8601 strings in JSON. Re-hydrate with new Date(value) on the consumer side, or use a reviver in JSON.parse.
Error message
- (no error — fields disappear)
JSON.stringify drops keys whose value is a function, undefined, or a Symbol. The output parses fine but is missing fields you expected.
Invalid
{
"name": "Ada",
"greet": function() {},
"nickname": undefined
}Valid
{
"name": "Ada",
"nickname": null
}Tip: If a field can be "missing", write null explicitly. If you need to send behaviour, send a string identifier and look it up on the other side.
Error message
- TypeError: Converting circular structure to JSON
- ValueError: Circular reference detected
JSON has no way to express a reference back to a parent object. JSON.stringify throws as soon as it walks into the same object twice.
Invalid
const a = { name: "Ada" };
a.self = a;
JSON.stringify(a); // throwsValid
const a = { name: "Ada" };
a.selfId = "a";
JSON.stringify(a);Tip: Replace circular pointers with IDs, or pass a replacer to JSON.stringify that tracks seen objects and writes a placeholder.
Error message
- json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
- Expecting value
Python's json.loads got something that isn't a JSON value at the position shown — most often an empty string, a Python repr (single quotes, True/False/None), or an HTML/text response from requests.get().text.
Invalid
>>> json.loads("{'a': 1}")
json.decoder.JSONDecodeError: Expecting value: line 1 column 2 (char 1)Valid
>>> json.loads('{"a": 1}')
{'a': 1}Tip: If you have a Python-formatted dict string, use ast.literal_eval() instead of json.loads().
Error message
- json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes
An object key is missing its double quotes. Common when copying Python dict, JS object literal, or YAML output into a JSON parser.
Invalid
{ name: "Ada", age: 30 }Valid
{ "name": "Ada", "age": 30 }Error message
- json.decoder.JSONDecodeError: Expecting ',' delimiter: line 3 column 3 (char 25)
- Expecting ',' delimiter
Two values appeared back-to-back inside an array or object without a comma between them. Often a missing comma after a multi-line string or object.
Error message
- json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 11 (char 10)
- Unterminated string in JSON
A string opened with " but never closed before the end of the document. Either the closing quote is missing or a line break inside the string was not escaped as \n.
Invalid
{ "msg": "hello world }Valid
{ "msg": "hello world" }Error message
- json.decoder.JSONDecodeError: Invalid control character at: line 1 column 12
- Invalid \escape
A raw newline, tab, or other control byte (U+0000–U+001F) is sitting inside a string literal. JSON requires those to be escaped as \n, \t, etc.
Invalid
{ "msg": "line 1
line 2" }Valid
{ "msg": "line 1\nline 2" }Tip: Python: json.loads(s, strict=False) tolerates these — but the resulting JSON is non-portable.
Error message
- json.decoder.JSONDecodeError: Invalid \escape: line 1 column 12 (char 11)
A backslash inside a string is followed by a character that isn't one of " \ / b f n r t u. \x, \a, \v, and bare \ are common offenders.
Invalid
{ "path": "C:\new" }Valid
{ "path": "C:\\new" }Error message
- Invalid \uXXXX escape
- invalid UTF-8 sequence at offset N
- json.decoder.JSONDecodeError: Invalid \uXXXX escape
A \u escape isn't followed by exactly four hex digits, or the file isn't valid UTF-8 (mixed encodings, broken multi-byte sequence).
Tip: Re-save the file as UTF-8 in your editor if it was Latin-1 / Windows-1252 originally.
Error message
- json: cannot unmarshal string into Go value of type int
- json: cannot unmarshal number into Go struct field
- json: cannot unmarshal array into Go value of type
The JSON parses fine, but the value type doesn't match the struct field. Often a number arrived as a quoted string ("42") or vice-versa.
Invalid
{ "age": "30" } // struct field: Age intValid
{ "age": 30 } // struct field: Age intTip: Use json.Number, a custom UnmarshalJSON, or change the struct field type to *string if the wire format is unstable.
Error message
- invalid character 'x' looking for beginning of value
- invalid character '\'' looking for beginning of object key string
- invalid character ',' looking for beginning of value
Go's encoding/json hit a character it didn't expect at that exact byte. The character in single quotes is the offender — usually a stray comma, single quote, or non-JSON token.
Error message
- unexpected end of JSON input
The reader closed before the parser saw a closing }, ], or ". Often an empty response body, a network read that was cut short, or a missing closing bracket.
Tip: Check len(body) before calling json.Unmarshal — empty body returns this exact error.
Error message
- EOF while parsing a value at line N column N
- EOF while parsing an object at line N column N
- EOF while parsing a string at line N column N
serde_json reached the end of input mid-value. The error tells you what it was looking for — a value, the rest of an object, or a closing string quote.
Error message
- trailing characters at line N column N
serde_json finished parsing one valid value and found more bytes after. Almost always two top-level values, or trailing whitespace + content from a bad concatenation.
Error message
- missing field `foo` at line N column N
- data did not match any variant of untagged enum
Parses as JSON but doesn't fit the Rust struct: a required field is absent. Add #[serde(default)] or wrap the field in Option<T> if it's truly optional.
Valid
{ "id": 1, "foo": "bar" }Error message
- Unexpected token { in JSON at position N
- Extra data: line 2 column 1
- trailing characters
NDJSON (newline-delimited JSON) and JSON Lines store one value per line. Feeding the whole file to a JSON parser fails — you have to split on \n and parse each line.
Invalid
{"id":1}
{"id":2}
{"id":3}Valid
// parse line by line
input.split('\n').filter(Boolean).map(line => JSON.parse(line))Tip: Or wrap with [ and ] and add commas between lines to convert NDJSON to a JSON array.
Error message
- Unexpected token i in JSON at position 0
- Expecting value: line 1 column 1
The input looks like a spreadsheet export, not JSON. The first character is a column header letter — JSON parsers reject that immediately.
Invalid
id,name,email
1,Ada,ada@example.com
Valid
[
{ "id": 1, "name": "Ada", "email": "ada@example.com" }
]Tip: Convert with a CSV-to-JSON tool first. Most spreadsheets can save as JSON via an extension.
Error message
- Unexpected token n in JSON at position 0
- Expecting value
YAML's indentation-based syntax has no brackets and no quotes around keys, so any JSON parser rejects it on the first character.
Invalid
name: Ada
items:
- one
- two
Valid
{
"name": "Ada",
"items": ["one", "two"]
}Tip: Every YAML document is convertible to JSON. Use yq or js-yaml to do it programmatically.
Error message
- Unexpected token < in JSON at position 0
XML opens with <?xml ...?> or <root>, both starting with <. A JSON parser fails on the first byte.
Invalid
<?xml version="1.0"?>
<user><id>1</id><name>Ada</name></user>
Valid
{ "user": { "id": 1, "name": "Ada" } }Error message
- Unexpected token % in JSON at position 0
- Expecting value
The JSON came from a query string or form field and is still percent-encoded. %7B is {, %22 is ", %3A is :. You need to decode it before parsing.
Invalid
%7B%22id%22%3A1%7D
Tip: Run decodeURIComponent() (JS) or urllib.parse.unquote() (Python) before JSON.parse.
Error message
- (no error — but the value is a string)
- Unexpected token \ in JSON at position N
A field contains a JSON string instead of a JSON value — the inner object was JSON.stringify'd twice. You parse the outer, get a string, and have to parse it again to get the object.
Invalid
{ "data": "{\"id\":1,\"name\":\"Ada\"}" }Valid
{ "data": { "id": 1, "name": "Ada" } }Tip: On the producing side, never call JSON.stringify on a value that's already a JSON string — pass the object directly.
Error message
- Unexpected token e in JSON at position 0
The string is base64 (often a JWT or an image). It looks like text but it's not JSON until you decode it — and even then, it might be binary.
Invalid
eyJpZCI6MSwibmFtZSI6IkFkYSJ9
Valid
{ "id": 1, "name": "Ada" }Tip: Decode with atob() in JS or base64.b64decode() in Python first. JWTs use three base64url segments separated by dots.
Error message
- Bad control character in string literal
- Invalid control character at: line N
On Windows, copying multi-line strings often pastes with \r\n. The \r is a control character and JSON forbids unescaped control characters in strings.
Invalid
{ "msg": "line one\r\nline two" } // raw bytesValid
{ "msg": "line one\nline two" }Tip: Run dos2unix on the file, or strip \r before stringifying.
Error message
- Unexpected token N in JSON at position N
- Unexpected token I in JSON at position N
MongoDB shells output extended JSON with helpers like ObjectId("..."), ISODate("..."), or NumberLong(...). Those are JS function calls, not JSON literals.
Invalid
{ "_id": ObjectId("507f1f77bcf86cd799439011"), "at": ISODate("2026-01-01") }Valid
{ "_id": { "$oid": "507f1f77bcf86cd799439011" }, "at": { "$date": "2026-01-01T00:00:00Z" } }Tip: Use mongoexport with --jsonFormat=canonical, or EJSON.stringify() in code.
Error message
- Unexpected token e in JSON at position 0
A JSON Web Token is three base64url segments separated by dots: header.payload.signature. Each segment is JSON once decoded — the whole thing is not.
Invalid
eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0In0.signature
Valid
{
"header": { "alg": "HS256" },
"payload": { "sub": "1234" }
}Tip: Split on '.', base64url-decode each part, then JSON.parse.
Error message
- Unexpected token / in JSON at position N
JSON has no regex type. /pattern/flags is a JavaScript literal. Strict parsers see the leading / and reject it.
Invalid
{ "match": /^abc$/i }Valid
{ "pattern": "^abc$", "flags": "i" }Tip: Send the source and flags as separate strings, then call new RegExp(source, flags) on the receiving side.
Error message
- Unexpected token o in JSON at position N
- Unexpected number in JSON
JSON has no octal notation. 0o755, 0755, and similar literals are language-specific and break every strict parser.
Invalid
{ "perms": 0o755, "umask": 0022 }Valid
{ "perms": "0755", "umask": "0022" }Tip: If the value matters as a number, convert to decimal: 0o755 → 493. If it matters as a literal (file modes), keep it as a string.
Error message
- Unexpected token b in JSON at position N
JSON only allows decimal numbers in standard notation. 0b1010 is a JavaScript / Python binary literal.
Invalid
{ "mask": 0b1010 }Error message
- Unexpected token _ in JSON at position N
JavaScript and Python allow underscores inside numbers for readability. JSON does not.
Invalid
{ "amount": 1_000_000 }Valid
{ "amount": 1000000 }Error message
- Unexpected token $ in JSON at position N
A backtick string with ${...} placeholders was used to build JSON, and the placeholder didn't get interpolated. The raw \${ landed in the output.
Invalid
{ "id": ${userId} }Tip: Don't string-concatenate JSON. Build a value and call JSON.stringify on it.
Error message
- Unexpected end of JSON input
- Expecting value: line 1 column 1 (char 0)
The input is empty or only whitespace. The smallest valid JSON document is a literal: null, true, false, a number, a string, [], or {}.
Error message
- Unexpected token , in JSON at position N
A comma appeared before the first element. Often happens when a templating engine emits a comma even when the loop has zero iterations.
Error message
- Unexpected string in JSON at position N
- Expecting ':' delimiter
An object key was followed by whitespace and then the value, with no colon between them. Often happens when copying YAML mapping into JSON.
Error message
- Unexpected token , in JSON at position N
Two commas back-to-back create an empty slot. JavaScript arrays allow this (and produce a sparse array); JSON does not.
Tip: If the slot is intentional, use null. If it's a typo, delete the extra comma.
Error message
- Unexpected token } in JSON at position N
- Unexpected token ] in JSON at position N
An array opened with [ but closed with } (or an object opened with { closed with ]). Usually a copy-paste accident across nested structures.
Invalid
{ "items": [1, 2, 3} }Valid
{ "items": [1, 2, 3] }Error message
- (no error — value is silently rounded)
JSON numbers are IEEE-754 doubles. Integers above 2^53 (9007199254740992) round to the nearest representable double on the way in or out.
Invalid
{ "id": 9007199254740993 } // becomes 9007199254740992Valid
{ "id": "9007199254740993" }Tip: Always send 64-bit IDs (Snowflake, Twitter, database IDs) as strings.
Error message
- (no parse error — but downstream consumers fail)
- json: cannot unmarshal string into Go value of type int
JSON allows arrays of mixed types, but most consumers assume one shape. A single string mixed into a list of numbers will break typed parsers (Go, Rust, TypeScript with strict types).
Invalid
{ "scores": [10, 20, "thirty", 40] }Valid
{ "scores": [10, 20, 30, 40] }