{}JSON FYI
Fix Invalid JSON

Fix Invalid JSON — Free Online Repair & Error Finder

Pinpoint exactly where JSON breaks, with a searchable catalog of every common JSON parser error and a working corrected example for each. 100% in-browser.

Ready when you are.

Paste JSON on the left, or click Sample to try a quick example. Validation runs as you type — entirely in your browser.

EmptyType: Nodes: 0Depth: 0Size: 0 B

The fastest way to fix invalid JSON

Most invalid JSON falls into one of about a dozen patterns: trailing commas, single quotes, unquoted keys, JavaScript-style comments, smart quotes from copy-paste, Python literals (True, None), or a missing closing bracket. The validator above tells you the exact line and column of the first offender — fix that one issue, re-validate, repeat.

If you have the exact error message your parser printed, paste it into the search box below to jump straight to the cause and corrected example.

Search by error message

Paste the exact error from your parser to find the matching fix.

Showing all 64 error patterns. Type to filter.

Unexpected token in JSON at position N

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.

Invalid
{
  "a": 1
  "b": 2
}
Valid
{
  "a": 1,
  "b": 2
}

Tip: The position number in the error tells you the byte offset — count from the start of the document.

Unexpected end of JSON input

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, 3
Valid
{
  "name": "Ada",
  "items": [1, 2, 3]
}

Trailing comma in object/array

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,
}
Valid
{
  "a": 1,
  "b": 2
}

Tip: If you really need trailing commas, switch to JSON5 or JSONC — they're not part of strict JSON.

Single quotes around keys or strings

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" }

Unquoted object keys

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" }

Comments (// or /* */) in JSON

Error message
  • Unexpected token / in JSON at position N
  • SyntaxError: Unexpected token

JSON has no comment syntax. Even // and /* */ that work in JS will break any compliant parser.

Invalid
{
  "id": 1, // user id
  "name": "Ada" /* full name */
}
Valid
{
  "_comment": "id is the user id, name is the full name",
  "id": 1,
  "name": "Ada"
}

Tip: Use a sibling field starting with _ as the convention for inline metadata. Or switch to JSONC if your parser supports it.

Unescaped newline or control character in string

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.

Smart/curly quotes from copy-paste

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.

Invalid
{ “name”: “Ada” }
Valid
{ "name": "Ada" }

Tip: Find-and-replace U+201C, U+201D, U+2018, U+2019 with straight " and ' before parsing.

NaN, Infinity, or undefined as a value

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.

Python literals (True, False, None)

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.

Leading zeros in numbers

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".

Hexadecimal or octal numbers

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.

Duplicate keys in the same object

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.

BOM (byte-order mark) at start of file

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" }
Valid
{ "name": "Ada" }

Tip: Save the file as "UTF-8 without BOM" in your editor, or strip the first byte before parsing.

Multiple top-level values

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.

Empty input

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 {}.

Invalid
(empty)
Valid
null

Invalid escape sequence in string

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.

Trailing or leading decimal point in number

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.

Explicit + sign on a number

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.

BigInt literal with trailing n

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.

Non-string object key (number, boolean, null)

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" }

Lone surrogate in \uXXXX escape

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.

JSONP callback wrapping the JSON

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.

HTML error page returned instead of JSON

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.

JavaScript Map or Set serialized to {}

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.

Invalid
{ "users": {} }
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.

Date serialized as a string (no Date type in JSON)

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.

Functions and undefined silently dropped by stringify

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.

Converting circular structure to JSON

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); // throws
Valid
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.

Expecting value: line N column N (char N)

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().

Expecting ',' delimiter

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.

Invalid
{
  "a": 1
  "b": 2
}
Valid
{
  "a": 1,
  "b": 2
}

Extra data: line N column N

Error message
  • json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 9)
  • Extra data

json.loads finished parsing one valid value and found more content after it. Usually two top-level objects (NDJSON) instead of an array, or a stray ] / } at the end of the file.

Invalid
{"id": 1}
{"id": 2}
Valid
[
  {"id": 1},
  {"id": 2}
]

Tip: For one-JSON-per-line files, read line by line and json.loads each line.

Unterminated string starting at: line N column N

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" }

Invalid control character at: line N column N

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.

Invalid \escape: line N column N

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" }

Invalid \uXXXX escape / invalid UTF-8 sequence

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).

Invalid
{ "x": "\u12" }
Valid
{ "x": "\u0012" }

Tip: Re-save the file as UTF-8 in your editor if it was Latin-1 / Windows-1252 originally.

Go: cannot unmarshal string into Go value of type int

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 int
Valid
{ "age": 30 }     // struct field: Age int

Tip: Use json.Number, a custom UnmarshalJSON, or change the struct field type to *string if the wire format is unstable.

Go: invalid character 'x' looking for beginning of value

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.

Invalid
{ 'name': 'Ada' }
Valid
{ "name": "Ada" }

Go: unexpected end of JSON input

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.

Invalid
{ "items": [1, 2,
Valid
{ "items": [1, 2] }

Tip: Check len(body) before calling json.Unmarshal — empty body returns this exact error.

Rust serde_json: EOF while parsing a value

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.

Invalid
{ "name": "Ada"
Valid
{ "name": "Ada" }

Rust serde_json: trailing characters

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.

Invalid
{"a":1}{"b":2}
Valid
[{"a":1},{"b":2}]

Rust serde_json: missing field `foo`

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.

Invalid
{ "id": 1 }
Valid
{ "id": 1, "foo": "bar" }

Multiple JSON values mixed up with NDJSON / JSONL

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.

CSV pasted into a JSON parser

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.

YAML pasted into a JSON parser

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.

XML pasted into a JSON parser

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" } }

URL-encoded JSON (still has %22 and %7B)

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
Valid
{ "id": 1 }

Tip: Run decodeURIComponent() (JS) or urllib.parse.unquote() (Python) before JSON.parse.

Double-encoded JSON (string of JSON inside JSON)

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.

Base64-encoded payload that isn't JSON

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.

CRLF line endings causing string corruption

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 bytes
Valid
{ "msg": "line one\nline two" }

Tip: Run dos2unix on the file, or strip \r before stringifying.

MongoDB extended JSON ($oid, $date, NumberLong)

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.

JWT token mistaken for JSON

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.

Regex literal /foo/ as a value

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.

Octal number with 0o or leading 0 prefix

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.

Binary literal 0b1010

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 }
Valid
{ "mask": 10 }

Template-literal placeholder leaked into JSON

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} }
Valid
{ "id": 42 }

Tip: Don't string-concatenate JSON. Build a value and call JSON.stringify on it.

Missing colon between key and value

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.

Invalid
{ "name" "Ada" }
Valid
{ "name": "Ada" }

Two commas in a row

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.

Invalid
[1, , 3]
Valid
[1, null, 3]

Tip: If the slot is intentional, use null. If it's a typo, delete the extra comma.

Mismatched brackets ([ closed by })

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] }

Large integer loses precision (silent rounding)

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 9007199254740992
Valid
{ "id": "9007199254740993" }

Tip: Always send 64-bit IDs (Snowflake, Twitter, database IDs) as strings.

Schema mismatch: heterogeneous array

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] }

Frequently asked questions

How do I fix invalid JSON?+

Paste it into the validator above and read the line/column of the first error. Most invalid JSON is one of: trailing commas, single quotes, unquoted keys, comments, or a missing closing bracket. Fix that one issue and re-validate.

What does "Unexpected token in JSON at position N" mean?+

The parser found a character it didn't expect at byte offset N. The most common causes are a missing comma between items, an extra trailing comma, or a stray bracket from copy-paste. Find that exact byte in your document.

Why does my JSON have an Unexpected end of input error?+

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 mid-stream.

Can I auto-fix JSON?+

Some errors are recoverable: trailing commas, single quotes, comments, and unquoted keys. Enable Lenient mode in the validator and the parser will accept those and warn instead of failing.

Is the repair done in my browser?+

Yes. JSON FYI never uploads your data — every byte stays local. Safe for production payloads, customer records, and API tokens.

Find JSON errors in code

Surface the exact line, column, and message in JS, Python, Go, and Ruby.

Catch the exact line and column of a syntax error

Most parsers print the offending position. Wrap parse() in a try/catch to surface it.

node check.js bad.json
import { readFileSync } from "node:fs";

const text = readFileSync(process.argv[2], "utf8");
try {
  JSON.parse(text);
} catch (e) {
  console.error(e.message);
  // Node 20+ includes a position; derive line/column manually.
  const m = /position (\d+)/.exec(e.message);
  if (m) {
    const offset = +m[1];
    const before = text.slice(0, offset);
    const line = before.split("\n").length;
    const col = offset - before.lastIndexOf("\n");
    console.error(`at line ${line}, column ${col}`);
  }
}
Input
{
  "a": 1,
  "b": 2,
}
Output
Unexpected token } in JSON at position 22
at line 4, column 1

Other JSON tools on JSON FYI

Every flow you need — formatter, validator, viewer, pretty print, repair, and the full workbench.

Related tools & guides