Why it happens
A JSON number cannot start with 0 unless it is 0 itself or a decimal like 0.5. Chrome and Node.js read the 0 of 02139, find another digit and stop: position 40 is the 2. Most common sources first:
1. Codes that look like numbers. ZIP codes, employee and product IDs, account numbers and PINs keep their leading zeros, and end up written without quotes.
2. Date and time parts. {"year": 2026, "month": 08} fails on the 8. A value padded with padStart(2, '0') and then pasted into a JSON template causes it.
3. Templates that insert raw values. `{"zip": ${zip}}` writes 02139 without quotes, even when zip is a string.
Firefox, Safari, Python and Go read the 0 as a finished number and then complain about the next digit, so they report a missing comma instead, as the messages above show.
The older meaning: a value where a comma belongs
Node.js 18 and older Chrome said Unexpected number for any number in the wrong place, and Unexpected string for any misplaced string:
JSON.parse('[1 2]'); // Node.js 18: Unexpected number in JSON at position 3
JSON.parse('{"a": 1 "b": 2}'); // Node.js 18: Unexpected string in JSON at position 8
Both are missing commas. Current versions report them as Expected ',' or ']' after array element and Expected ‘,’ or ‘}’ after property value.
How to fix unexpected number in JSON
Quote values that are codes
{
"customer": "Lena Ortiz",
"zip": "02139",
"plan": "team"
}
If you would never do arithmetic on it, store it as a string. Drop the zero only for real quantities: "month": 8.
Build JSON with a serializer
const zip = '02139';
JSON.stringify({ zip }); // {"zip":"02139"}
json.dumps({"zip": "02139"}) gives the same in Python. Converting to a number first loses the zero: Number('02139') is 2139.
Repair
The JSON validator names the value: Number 02139 has a leading zero. JSON Repair quotes such numbers, so 02139 becomes "02139" and keeps its zero.
Same error in other languages
- Python:
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 3 column 11 (char 40). A lone01givesExtra datainstead. - Go:
invalid character '2' after object key:value pair - PHP:
json_last_error_msg()returnsSyntax error.
Other numbers JSON rejects (+5, .5, 5., hex) are listed in common JSON errors.