Formatter Validator Minifier Escape / Unescape JSON ↔ String JSON ↔ YAML JSON → CSV NDJSON / JSON Lines JSON → Types JSON ↔ XML JSON Diff JSON Patch Canonicalize (RFC 8785) Schema Validator Schema Generator JSONPath Tester JWT Decoder JSON Errors Schemas More Tools
JSONTools / JSON errors / JSON Parse error: Unexpected identifier "NaN"
JavaScriptCore JSON.parse · JavaScriptCore (Bun 1.4.1)

JSON Parse error: Unexpected identifier "NaN"

This message comes from JavaScriptCore JSON.parse on JavaScriptCore (Bun 1.4.1). In this registry it is produced by 1 distinct mistake. Positions in the real message vary with your input; the causes do not.

What produces this message

NaN is not valid JSON

Input
{"a": NaN}

Exact message: JSON Parse error: Unexpected identifier "NaN"

Fix: Emit `null` instead, or a sentinel your consumer understands. In Python, pass `allow_nan=False` to `json.dumps` so the problem surfaces at write time rather than at read time in someone else's service.

What other parsers say about the same input

If a colleague reports a different message for what looks like the same file, this is why.

Parser Message for the same inputs
JSON::PPmalformed JSON string, neither array, object, number, string or atom, at character offset N (before "…")
Jackson ObjectMapperNon-standard token 'NaN': enable `JsonReadFeature.ALLOW_NON_NUMERIC_NUMBERS` to allow
Ruby JSON.parseunexpected token at '…'
SpiderMonkey JSON.parseJSON.parse: unexpected character at line L column C of the JSON data
System.Text.Json Deserialize'N' is an invalid start of a value. Path: $ | LineNumber: L | BytePositionInLine: C.
System.Text.Json JsonDocument'N' is an invalid start of a value. LineNumber: L | BytePositionInLine: C.
V8 JSON.parseUnexpected token 'N', "{"a": NaN}" is not valid JSON
encoding/json Unmarshalinvalid character 'N' looking for beginning of value
hjsonEnd of input while parsing an object (missing '}') at line L,10
json-bigintUnexpected 'N'
json_decodeSyntax error
orjsonunexpected character, expected a JSON value: line L column C (char N)
serde_json::from_strexpected value at line L column C

← All JSON parser errors

Standards this registry is checked against

Only standards bodies and peer-reviewed venues are cited. Error strings on this site are observed by executing each parser; the standards above define what the parser is reacting to.