JSON Data Types

What you’ll learn
JSON (JavaScript Object Notation) is a lightweight text format for exchanging data between browsers, servers, databases, and tools. Every JSON document is built from a small set of value types defined in RFC 8259.
This page walks through each type with short examples, then shows one nested document that mixes them the way real APIs do.
What is JSON?
JSON uses JavaScript–like literal syntax, but it is language independent. Data is expressed as a single JSON value at the top level—usually an object or an array—whose properties and elements use only the six types below.
The six JSON value types
A conforming parser recognises exactly these kinds of values. Anything else (for example a date type, undefined, or NaN) must be represented using one of these types plus an agreed convention.
String
Unicode text in double quotes, with escape sequences for control characters and quotes.
Number
Decimal digits; optional -, fraction, and exponent. No NaN or Infinity in strict JSON.
Boolean
Literals true and false (never quoted).
Null
Literal null for “no value” or unknown (not an empty string).
Array
Ordered list in [ ]; elements may have mixed types.
Object
Map of string keys to values in { }; order is not semantically meaningful to the spec.
String
Strings are sequences of Unicode characters wrapped in double quotes. Use backslash escapes for quotes, backslashes, newlines, and other control characters.
{
"name": "John Doe",
"message": "Hello, World!",
"slug": "docs/api/overview"
}Number
Numbers are not quoted. They may be integers, fractions, or use scientific notation with e or E.
{
"age": 30,
"height": 5.9,
"scientific": 1.23e4
}Boolean
Booleans are the lowercase literals true and false without quotes.
{
"isStudent": true,
"hasGraduated": false
}Null
null represents an intentional empty value. It is not the same as omitting the key or using an empty string.
{
"middleName": null
}Array
Arrays are ordered lists in square brackets. Elements can be any JSON value, including nested arrays and objects.
{
"fruits": ["apple", "banana", "cherry"],
"numbers": [1, 2, 3, 4, 5],
"mixed": ["text", 123, false, null]
}Object
Objects are unordered collections of key–value pairs. Keys must be strings; values can be any type. Nest objects to model structured records.
{
"person": {
"firstName": "Jane",
"lastName": "Doe",
"age": 25,
"address": {
"street": "123 Main St",
"city": "Anytown",
"zipcode": "12345"
},
"phoneNumbers": ["555-1234", "555-5678"]
}
}Example: one document, every type
This payload combines strings, numbers, booleans, null, arrays, and nested objects—the shape you often see from REST APIs.
{
"employee": {
"id": 101,
"name": "Alice",
"email": "alice@example.com",
"isManager": false,
"department": null,
"skills": ["JavaScript", "Python", "HTML", "CSS"],
"projects": [
{
"name": "Project A",
"deadline": "2026-06-30",
"budget": 10000.5
},
{
"name": "Project B",
"deadline": "2026-12-31",
"budget": 20000.75
}
]
}
}The outer value is an object with one key, employee, whose value is another object. Arrays hold primitives in skills and objects in projects.
Key takeaways
JSON has exactly six value types: string, number, object, array, boolean, and null.
Object keys are always strings in double quotes; numbers and dates are carried as numbers or strings by convention.
Strict JSON rejects NaN, Infinity, trailing commas, and unquoted keys—watch what your serializer emits.
Frequently asked questions
Next: JSON Rules
Once you know the types, learn the syntax rules that keep documents valid for every parser.
JSON text is built from exactly six kinds of value. There is no separate “date” or “binary” type in the core spec — you represent those as strings (often ISO‑8601) or Base64 in a string, and document the convention in your API or schema.
10 people found this page helpful
