JSON Data Types

Beginner
5 min read
Updated: Nov 2026
3 examples

Definition and Usage

Every JSON value is one of six types: string, number, object, array, boolean, or null. A JSON document is just nested values of those kinds.

There is no built-in date, binary, or undefined type. Dates are usually strings (often ISO-8601). JSON Schema can describe those conventions with the type and format keywords.

Beginner path.

Learn the six types below, then open the examples. Next stop in this tutorial is JSON Rules.

The Six Types

  • string Text in double quotes — "Ada"
  • number Integers or decimals — 42, 3.14 (no NaN / Infinity)
  • object Curly braces with quoted keys — {"id": 1}
  • array Ordered list in square brackets — [1, 2, 3]
  • boolean Exactly true or false
  • null The literal null — meaning “empty” / no value

JSON Schema type

Schemas name expected types with the type keyword — for example "type": "string", or several options as an array: "type": ["string", "null"].

Schema also adds integer (whole numbers) as a distinct check, even though JSON text still writes them as numbers. Use format (like date-time) when a string carries special meaning.

JSON
{
  "type": "object",
  "properties": {
    "name": { "type": "string" },
    "age": { "type": "integer" },
    "active": { "type": "boolean" },
    "nickname": { "type": ["string", "null"] }
  }
}

Examples

Use View Output for a quick result, or Try It Yourself to edit and run in the browser.

Example 1 — All Six Types

One object that uses every JSON value kind.

JSON
const data = {
  name: "Ada",          // string
  age: 36,              // number
  active: true,         // boolean
  skills: ["math"],     // array
  address: { city: "London" }, // object
  nickname: null        // null
};

console.log(data.name);
console.log(data.age);
console.log(data.active);
console.log(data.skills[0]);
console.log(data.address.city);
console.log(data.nickname);
Try It Yourself

How It Works

  1. Each property holds one of the six JSON types.
  2. Arrays and objects nest other values.
  3. null is a real value — not the same as a missing key.

Example 2 — Check Types with typeof

See how JavaScript labels each kind after you have the values.

JSON
const data = {
  name: "Ada",
  age: 36,
  active: true,
  skills: ["math"],
  address: { city: "London" },
  nickname: null
};

console.log(typeof data.name);      // string
console.log(typeof data.age);       // number
console.log(typeof data.active);    // boolean
console.log(Array.isArray(data.skills)); // true
console.log(typeof data.address);   // object
console.log(data.nickname === null); // true
Try It Yourself

How It Works

  1. Use typeof for string, number, and boolean.
  2. Arrays are objects in JS — check with Array.isArray.
  3. typeof null is also "object" — compare with === null.

Example 3 — Nested Object and Array

Most API payloads mix objects and arrays.

JSON
const user = {
  id: 1,
  name: "Ada",
  roles: ["admin", "editor"],
  profile: {
    city: "London",
    verified: true
  }
};

console.log(user.roles[0]);
console.log(user.profile.city);
console.log(user.profile.verified);
Try It Yourself

How It Works

  1. roles is an array of strings.
  2. profile is a nested object.
  3. Read nested values with dot and index access.

Frequently Asked Questions

Six: string, number, object, array, boolean, and null. There is no date, binary, or undefined type in core JSON.
In JSON text, numbers are one type. JSON Schema adds an integer keyword for whole numbers, separate from number.
Use a string, often ISO-8601 such as 2018-11-13T20:20:39+00:00. JSON Schema can annotate it with format: date-time.
undefined is not a JSON value. JSON.stringify omits undefined object properties and turns undefined array slots into null.

Next: JSON Rules

Learn the rules that keep JSON valid.

JSON Rules tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful