Formatter Validator Minifier Escape / Unescape JSON ↔ String JSON ↔ YAML JSON → CSV NDJSON / JSON Lines JSON → Types JSON ↔ XML JSON Diff JSON Patch Canonicalize (RFC 8785) Schema Validator Schema Generator JSONPath Tester JWT Decoder JSON Errors Schemas More Tools
JSONTools / JSON errors / Python True / False / None in JSON
JSON error registry · Invalid literal

Python True / False / None in JSON

Python's `repr` of a dict writes `True`, `False` and `None`. JSON requires the lowercase `true`, `false` and `null`.

The input

Fails to parse
{"a": True, "b": None}
Parses correctly
{"a": true, "b": null}

Open this broken input in the formatter →

How to fix it

Serialise with `json.dumps()` rather than `str()`, `repr()`, or an f-string.

If you already have the broken text and cannot regenerate it, `ast.literal_eval` will read a Python dict repr safely — do not use `eval`.

What each parser reports

Every message below was captured by running this exact input through the parser named. 19 of 21 parsers rejected it; 2 accepted it.

Parser Exact message
CPython json.loads
CPython 3.12.3
Expecting value: line 1 column 7 (char 6)
what this message means →
encoding/json Unmarshal
Go go1.22.2
invalid character 'T' looking for beginning of value
what this message means →
Gson
Java 21.0.12
accepted — no error
Gson JsonParser (lenient off)
Java 21.0.12
accepted — no error
hjson
Node.js 22.22.2
End of input while parsing an object (missing '}') at line 1,22 >>>"a": True, "b": None ...
what this message means →
Jackson ObjectMapper
Java 21.0.12
Unrecognized token 'True': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
what this message means →
JavaScriptCore JSON.parse
JavaScriptCore (Bun 1.4.1)
JSON Parse error: Unexpected identifier "True"
what this message means →
json-bigint
Node.js 22.22.2
Unexpected 'T'
JSON5
Node.js 22.22.2
JSON5: invalid character 'T' at 1:7
what this message means →
JSON::PP
Perl 5.038002
malformed JSON string, neither array, object, number, string or atom, at character offset 6 (before "True, "b": None}")
what this message means →
json_decode
PHP 8.3.6
Syntax error
Newtonsoft.Json JsonConvert
Newtonsoft.Json 13.0.3 on .NET 8.0.30
Unexpected character encountered while parsing value: T. Path 'a', line 1, position 6.
what this message means →
Newtonsoft.Json JsonTextReader
Newtonsoft.Json 13.0.3 on .NET 8.0.30
Unexpected character encountered while parsing value: T. Path 'a', line 1, position 6.
what this message means →
orjson
CPython 3.12.3
unexpected character, expected a JSON value: line 1 column 7 (char 6)
what this message means →
Ruby JSON.parse
Ruby 3.2.3
unexpected token at '{"a": True, "b": None}'
serde_json::from_str
Rust (serde_json 1.x)
expected value at line 1 column 7
what this message means →
SpiderMonkey JSON.parse
SpiderMonkey 115
JSON.parse: unexpected character at line 1 column 7 of the JSON data
what this message means →
System.Text.Json Deserialize
.NET 8.0.30
'T' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 6.
what this message means →
System.Text.Json JsonDocument
.NET 8.0.30
'T' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 6.
what this message means →
ujson
CPython 3.12.3
Expected object or value
V8 JSON.parse
Node.js 22.22.2
Unexpected token 'T', "{"a": True, "b":"... is not valid JSON
what this message means →

What the specification says

The exact sections that govern this error. Descriptions are our paraphrase; follow the links for the normative text.

Body Section
IETF
A value must be an object, array, number, string, or one of the three literal names, which the section states must be lowercase. No other literal names are allowed.
Ecma International
Lists the six structural tokens, the three literal name tokens, and the four whitespace code points. Whitespace is not allowed within a token.

Other errors in this category

NaN is not valid JSON

`NaN` has no representation in JSON. It appears when a language serialises a floating-point not-a-number without checking — Python…

Infinity is not valid JSON

Same root cause as NaN — a float overflowed and the serialiser wrote `Infinity` or `-Infinity`, which the JSON grammar has no toke…

undefined is not valid JSON

`undefined` is a JavaScript value with no JSON equivalent. `JSON.stringify` normally drops undefined object properties, so seeing …

← All JSON parser errors