</>
ValidateHTML

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

Invalid JSON
{
  "name": "John",
  "age": NaN,
  "salary": Infinity,
  "callback": undefined,
  "active": True
}
Valid JSON
{
  "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 Validator
Recommended

Hostinger Fast & Affordable Web Hosting

Deploy clean, validated JSON APIs on reliable hosting.

Get 80% Off Hosting →

Related JSON Errors

View all JSON errors