Skip to main content

Boolean

RFC 8259 §3

true | false

JSON booleans are the lowercase literals true and false. No other casing is valid – True, False, TRUE, FALSE are all syntax errors. Boolean values are distinct from 0/1 and from the strings 'true'/'false'. JSON has no truthy/falsy concept – only strict true and false.

Description

The JSON boolean type has exactly two values: true and false, both lowercase. This is one of the most common sources of bugs when moving between languages. Python uses True and False (capitalized), which are not valid JSON. YAML uses true, false, yes, no (case-insensitive), none of which map directly.

In API design, the choice between boolean values and string enums matters for extensibility. A boolean field isPrimary can only ever be true or false. A string field status can grow from active/inactive to active/inactive/pending/suspended without breaking changes.

Examples

LabelValue
Truetrue
Falsefalse
In object{"active": true, "admin": false}

Common Gotchas

!

Must be lowercase – True and False are not valid JSON

!

Distinct from the strings "true" and "false" – they are different types

!

Distinct from 1 and 0 – JSON has no implicit boolean coercion

!

Python's True/False serialize correctly via json.dumps() but are not valid JSON if typed manually

!

YAML 1.1 treats yes/no/on/off as booleans – these are strings in JSON

See Also