JSON Schema Types

The type keyword defines what kind of data a field is allowed to contain. JSON Schema includes seven built-in types: five primitive types that hold a single value, and two composite types that group values together.

Primitive Types

string

Text — any sequence of characters: letters, digits, symbols, spaces. The most versatile type; use it for names, descriptions, addresses, codes, and any other free-form text. Supports formats for semantic validation.

ValueStatusNote
"hello"
valid
""
valid
empty string is still a string
"42"
valid
a number written as text is still a string
42
invalid
this is a number, not a string

number

Any numeric value — whole or decimal. Covers integers, fractions, and scientific notation. Use when a fractional value may be needed: prices, distances, weights, ratings. For whole numbers only, prefer integer.

ValueStatusNote
42
valid
3.14
valid
-7
valid
0
valid
1.5e10
valid
scientific notation is accepted
"42"
invalid
a string containing digits is not a number

integer

A whole number — no fractional part. Use when only round values make sense: counts, IDs, ages, page numbers, quantities. If fractions are possible, use number instead. Decimal notation like 1.0 is accepted as long as the fractional part is zero.

ValueStatusNote
0
valid
42
valid
-5
valid
1.0
valid
fractional part is zero — treated as an integer
3.14
invalid
non-zero fractional part
"42"
invalid
string, not a number

boolean

A true/false value. Use for on/off switches, yes/no answers, active/inactive flags, or any field that has exactly two states. Note: JSON booleans are lowercase true and false, not strings or numbers.

ValueStatusNote
true
valid
false
valid
"true"
invalid
the word "true" as text is not a boolean
1
invalid
in JSON, 1 is not the same as true
0
invalid
null
invalid
null is the absence of a value, not false

null

The intentional absence of a value — "this field has no value." In JSON, null is its own distinct type, not zero, not an empty string, not false. Often combined with another type (e.g. string or null) using anyOf to mark a field as optionally empty.

ValueStatusNote
null
valid
""
invalid
an empty string is still a string, not null
0
invalid
zero is a number, not null
false
invalid
false is a boolean, not null
"null"
invalid
the word "null" as text is not null

Composite Types

array

An ordered list of values. Items appear in sequence and can be accessed by position (first, second, third…). Use for collections where order matters: tags, search results, cart items, a list of phone numbers. The optional itemskeyword constrains what type each element must be.

ValueStatusNote
[]
valid
empty list
["apple", "banana", "cherry"]
valid
[1, 2, 3]
invalid
numbers are not strings
"apple, banana"
invalid
comma-separated text is a string, not an array

object

A structured set of named fields (key-value pairs). Use for records, profiles, addresses, and settings — any entity with multiple attributes. The propertieskeyword defines the shape of the object, and requiredlists which fields must always be present.

ValueStatusNote
{}
invalid
missing required field 'name'
{"name": "Alice", "age": 30}
valid
{"name": "Bob"}
valid
optional fields can be omitted