Boolean Values in JSON: How true and false Work and What Breaks Them

How JSON booleans work, how true differs from "true", 1 and True, and whether formatting, validation, conversion and copy-paste keep their meaning.

JSON has exactly two boolean values: true and false. This overview covers how they are written, how they differ from values that look similar, and whether common steps such as formatting, validation, type conversion and copy-paste keep their meaning.

What a boolean is in JSON

The JSON standard (RFC 8259, aligned with ECMA-404) defines three literal names: true, false and null. The booleans are true and false. They must be lowercase and unquoted. With quotes they become strings, and with any other capitalization they are invalid JSON.

{
  "active": true,
  "verified": false,
  "tags": [true, false, true]
}

How booleans differ from look-alike values

Written as | What JSON sees
true / false | Boolean
"true" / "false" | String containing the word
True / TRUE / False | Invalid JSON (parse error)
1 / 0 | Number
null | Null, which is a separate value from false
yes / no / on / off (unquoted) | Invalid JSON

The string case causes the most trouble because it passes syntax checks. A parser accepts "false" without complaint and hands the program a string. In languages where any non-empty string counts as truthy, that string then behaves like true. In JavaScript, Boolean("false") returns true, and in Python, bool("false") returns True.

const data = JSON.parse('{"enabled": "false"}');
if (data.enabled) {
  // This branch runs: "false" is a non-empty string
}

What formatting and validation change, and what they leave alone

Pretty-printing, minifying and re-indenting change only the whitespace between tokens. The tokens true and false come out identical, so formatting is safe for boolean data. Some tools also reorder object keys. That does not change any values, although it can make diffs harder to read.

A syntax validator rejects True, TRUE and unquoted yes, because none of them are valid JSON. It accepts "true", because a quoted word is a valid string. Syntax validation cannot tell you whether a field was meant to be a boolean. A schema can. In JSON Schema, "type": "boolean" rejects strings, numbers and null for that field.

{
  "type": "object",
  "properties": {
    "active": { "type": "boolean" }
  },
  "required": ["active"]
}

Type conversion: when the stored value actually changes

Formatting changes presentation. Conversion changes data. Turning "true" into true, or 1 into true, changes the value's type, and every consumer of the data will see that change. When you convert, list the accepted spellings explicitly and treat anything else as an error. Generic truthiness rules silently turn "false", "0" and "no" into true.

function toBoolean(value) {
  if (value === true || value === "true") return true;
  if (value === false || value === "false") return false;
  throw new Error(`Not a boolean: ${JSON.stringify(value)}`);
}

Will booleans survive copying and sharing?

  • Python output is not JSON. Printing a Python dict shows True, False and single quotes, and a JSON parser rejects all three. Use json.dumps, which writes true and false.
  • Word processors and some chat or note apps replace straight quotes with curly ones. The booleans themselves have no quotes, but the keys around them do, so the whole document stops parsing.
  • Autocorrect and autocapitalize in editors or on mobile keyboards can change true to True, especially at the start of a line.
  • Spreadsheets show booleans as TRUE and FALSE. After a CSV export they are plain text, so converting back to JSON needs an explicit mapping.
  • YAML 1.1 parsers treat unquoted yes, no, on and off as booleans. Converting YAML to JSON can therefore produce true or false where a string was intended, for example a country code like NO.
  • Styled Unicode text, such as decorative font generators or fullwidth letters, uses different code points from plain ASCII. A styled version of true is not the literal true, and it will not parse as a boolean.

For readability, true and false are ordinary lowercase English words, and nothing about their encoding should get in the way of reading or editing them. No tests of specific editors, messaging apps or screen readers were available for this article. Behavior in any particular destination is not confirmed here, so check a small sample in the tools you actually use.

Is a boolean the right choice for your field?

Use true and false when a field genuinely has two states and both states mean something. Booleans are unambiguous, compact and easy to enforce with a schema. The tradeoff is that they leave no room for a third state. If the field later needs a value like pending or unknown, adding one is a breaking change for consumers. If a third state is plausible, a string enum such as "active", "disabled" or "pending" is usually safer. If you use null to mean unknown, document that meaning.

Plain-text strings are the better choice when the value is a human-facing label, or when it passes through channels that carry only text, such as CSV files, URL query parameters and environment variables. In those cases, document the exact accepted spellings and convert them explicitly at the boundary where the data re-enters JSON.

Quick checklist

  • Write booleans in lowercase and without quotes: true, false.
  • Do not treat null as a synonym for false.
  • Use a schema with "type": "boolean" to catch "true" strings and 1 or 0 numbers.
  • Treat pretty-printing and minifying as safe; treat type conversion as a data change.
  • Convert strings to booleans with an explicit mapping, never with generic truthiness.
  • Generate JSON with a serializer rather than copying a language's print output.
  • Re-validate JSON after pasting it through editors, chat tools or documents.

Sources and limits: this overview relies on the JSON standard and documented language behavior. No tool-specific measurements or test results were supplied, so it makes no claims about how any particular formatter, validator or app performs.