Skip to main content

Null

RFC 8259 §3

null

JSON null represents the intentional absence of a value. It is a first-class type, not a string or number. null is distinct from undefined (JavaScript), None (Python), nil (Ruby/Go), and a missing key. A key with a null value exists in the object; a missing key does not.

Description

null in JSON signals that a value is intentionally absent or unknown. This is semantically distinct from an empty string, zero, false, or an empty array – all of which are defined values. null means 'no value here'.

The critical distinction is between a missing key and a key with a null value: {"name": null} – the name field exists, its value is null {} – the name field does not exist at all

In APIs this matters: a PATCH request sending {"email": null} typically means 'clear this field', while sending {} means 'don't change this field'. Many bugs arise from conflating these two states.

Examples

LabelValue
Null valuenull
Null field{"middleName": null}
Null vs missing{"a": null} vs {} // different semantics
Nullable array item[1, null, 3]

Common Gotchas

!

Must be lowercase – Null and NULL are not valid JSON

!

Distinct from the string "null" – different types

!

A field set to null is different from a field that is absent – API semantics often differ

!

JavaScript undefined does not exist in JSON – undefined properties are omitted during JSON.stringify()

!

In PATCH APIs: {"field": null} usually means clear/unset; {} means no change

See Also