Invalid Value Type in JSON
JSON supports exactly six value types: strings (double-quoted), numbers, booleans (true/false), null, objects, and arrays. Values like undefined, NaN, Infinity, functions, dates, and regex are not valid JSON. These values exist in JavaScript but have no JSON representation.
Why It Matters
The JSON parser rejects the document immediately. This commonly happens when using JSON.stringify() on JavaScript objects that contain undefined values, Date objects, or functions.
Code Examples
{
"name": "John",
"age": NaN,
"salary": Infinity,
"callback": undefined,
"active": True
}{
"name": "John",
"age": null,
"salary": 999999,
"callback": null,
"active": true
}How to Fix
- 1Replace undefined with null or remove the property entirely.
- 2Replace NaN and Infinity with null or a sentinel number value.
- 3Use lowercase true, false, and null. JSON is case-sensitive: True, False, and None are invalid.
- 4Convert Date objects to ISO strings before serializing: new Date().toISOString().
Check Your JSON Now
Our JSON validator detects this error automatically and shows the exact line and column.
Open JSON ValidatorHostinger — Fast & Affordable Web Hosting
Deploy clean, validated JSON APIs on reliable hosting.
Related JSON Errors
Unexpected Token in JSON
Learn why JSON throws an unexpected token error and how to fix it. Common causes include trailing commas, single quotes, and unquoted keys.
Single Quotes in JSON
JSON requires double quotes for all strings and keys. Learn how to fix the single quotes error.
Invalid Escape Characters in JSON
Learn which escape sequences are valid in JSON strings and how to fix invalid ones.