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.
Common Causes
- Serializing a JavaScript object that holds undefined, NaN, Infinity, a function, or a Date by hand instead of through JSON.stringify.
- Writing booleans or null with the wrong casing, such as True, False, or None copied from Python.
- Leaving a bare value like a Date or a regex literal in the data, which has no JSON equivalent.
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().
Frequently Asked Questions
What value types does JSON actually support?
How does JSON.stringify handle undefined and functions?
How should I store a date in JSON?
Check Your JSON Now
Our JSON validator detects this error automatically and shows the exact line and column.
Open JSON ValidatorCloudways · Managed Cloud Hosting
Fix this JSON error, then deploy on Cloudways managed cloud (AWS, GCP, DigitalOcean).
Free 3-day trial · 30% off 3 months + free site migration with code MIGRATE303
Related JSON Errors
Unexpected Token in JSON
Fix the unexpected token error in JSON fast. See why parsers fail on trailing commas, single quotes, unquoted keys, and comments, with clear examples.
Single Quotes in JSON
JSON requires straight double quotes for every string and key, so single quotes always break parsing. Learn how to fix the single quotes error fast.
Invalid Escape Characters in JSON
Learn which escape characters are valid in JSON strings and how to fix the invalid ones. Windows file paths and regex patterns are the usual culprits.