Most JSON errors are loud — JSON.parse() throws a SyntaxError, the console lights up, and you know exactly where to look. But some JSON bugs are silent. They parse successfully, return no error, and then corrupt your data in ways that only surface later — a wrong price, a missing field, or a test that passes locally and fails in production.
This guide covers the most dangerous silent JSON errors: duplicate keys, UTF-8 BOM characters, floating-point precision loss on large integers, deep nesting that hits parser stack limits, and invisible control characters inside string values.
1. Duplicate Keys
The JSON specification says keys within an object SHOULD be unique but does not forbid duplicates. In practice, most parsers silently take the last value. {"id":1,"id":2} parses to {"id":2} with zero warnings. The first value is quietly dropped — a common source of subtle bugs in responses built by templating code.
2. BOM Characters
A UTF-8 Byte Order Mark (U+FEFF) at the start of a JSON string causes JSON.parse() to throw in Node.js and most browsers. The BOM is invisible in most editors so the file looks valid. Strip it before parsing: str.replace(/^/, '').
3. Number Precision Loss
JavaScript uses 64-bit floats for all numbers. Integers larger than Number.MAX_SAFE_INTEGER (9007199254740991) lose precision silently. A JSON field like {"id":9999999999999999} will parse as 10000000000000000. Use BigInt or transmit large IDs as strings.
4. Control Characters in Strings
Unescaped control characters (ASCII 0x00–0x1F) inside a JSON string are technically invalid but many parsers accept them silently. When the string is later re-serialized or transmitted to a stricter parser, it may fail. Always sanitize user-generated content before embedding it in JSON.
Validate JSON before it reaches production
The UnblockDevs JSON Validator catches duplicate keys, encoding issues, and structural errors that standard parsers miss.
Open JSON Validator →