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 / unexpected character, expected a string key: line
orjson · CPython 3.12.3

unexpected character, expected a string key: line L column C (char N)

This message comes from orjson on CPython 3.12.3. In this registry it is produced by 9 distinct mistakes. Positions in the real message vary with your input; the causes do not.

What produces this message

/* */ comments are not valid JSON

Input
{ /* note */ "a": 1 }

Exact message: unexpected character, expected a string key: line 1 column 3 (char 2)

Fix: Remove them, or switch the file to JSONC/JSON5 and use a parser for that dialect.

Comma in an empty JSON object

Input
{,}

Exact message: unexpected character, expected a string key: line 1 column 2 (char 1)

Fix: Remove the comma. An empty object is `{}`.

JavaScript object literal passed off as JSON

Input
{a: 1, b: 'two', c: [3,],}

Exact message: unexpected character, expected a string key: line 1 column 2 (char 1)

Fix: Run it through `JSON.stringify()` from JavaScript, or convert by hand: quote the keys, switch to double quotes, drop the trailing commas.

// comments are not valid JSON

Input
{
  // note
  "a": 1
}

Exact message: unexpected character, expected a string key: line 2 column 3 (char 4)

Fix: Strip the comments, or parse with a JSONC-aware reader if you control the consumer.

Numeric object key in JSON

Input
{1: "a"}

Exact message: unexpected character, expected a string key: line 1 column 2 (char 1)

Fix: Quote the key: `{"1": "a"}`.

Python dict repr passed off as JSON

Input
{'a': 1, 'b': [1, 2]}

Exact message: unexpected character, expected a string key: line 1 column 2 (char 1)

Fix: Use `json.dumps()`. If you only have the broken text, `ast.literal_eval()` reads it safely.

Single-quoted strings in JSON

Input
{'a': 1}

Exact message: unexpected character, expected a string key: line 1 column 2 (char 1)

Fix: Replace every single quote used as a string delimiter with a double quote. Watch for apostrophes inside the text — those stay as they are.

Curly (smart) quotes in JSON

Input
{“a”: 1}

Exact message: unexpected character, expected a string key: line 1 column 2 (char 1)

Fix: Replace them with straight ASCII quotes, and turn off smart quotes in whatever produced the text.

Unquoted object key in JSON

Input
{a: 1}

Exact message: unexpected character, expected a string key: line 1 column 2 (char 1)

Fix: Wrap every key in double quotes.

What other parsers say about the same input

If a colleague reports a different message for what looks like the same file, this is why.

Parser Message for the same inputs
CPython json.loadsExpecting property name enclosed in double quotes: line L column C (char N)
GsonExpected name at line L column C path $…
Gson JsonParser (lenient off)Expected name at line L column C path $…
JSON5JSON5: invalid character ',' at 1:2JSON5: invalid character '1' at 1:2JSON5: invalid character '“' at 1:2
JSON::PPunexpected end of string while parsing JSON string, at character offset N (before "…")
Jackson ObjectMapperUnexpected character (''' (code 39)): was expecting double-quote to start field nameUnexpected character (',' (code 44)): was expecting double-quote to start field nameUnexpected character ('/' (code 47)): maybe a (non-standard) comment? (not recognized as one since Feature 'ALLOW_COMMENTS' not enabled for parser)Unexpected character ('1' (code 49)): was expecting double-quote to start field nameUnexpected character ('?' (code 8220 / 0x201c)): was expecting double-quote to start field nameUnexpected character ('a' (code 97)): was expecting double-quote to start field name
JavaScriptCore JSON.parseJSON Parse error: Expected '}'JSON Parse error: Single quotes (') are not allowed in JSONJSON Parse error: Unrecognized token '/'JSON Parse error: Unrecognized token '“'
Newtonsoft.Json JsonConvertInvalid property identifier character: ,. Path '', line L, position N.Invalid property identifier character: “. Path '', line L, position N.
Newtonsoft.Json JsonTextReaderInvalid property identifier character: ,. Path '', line L, position N.Invalid property identifier character: “. Path '', line L, position N.
Ruby JSON.parseunexpected token at '…'
SpiderMonkey JSON.parseJSON.parse: expected property name or '}' at line L column C of the JSON data
System.Text.Json Deserialize''' is an invalid start of a property name. Expected a '"'. Path: $ | LineNumber: L | BytePositionInLine: C.',' is an invalid start of a property name. Expected a '"'. Path: $ | LineNumber: L | BytePositionInLine: C.'/' is invalid after a value. Expected either ',', '}', or ']'. Path: $ | LineNumber: L | BytePositionInLine: C.'0xE2' is an invalid start of a property name. Expected a '"'. Path: $ | LineNumber: L | BytePositionInLine: C.'1' is an invalid start of a property name. Expected a '"'. Path: $ | LineNumber: L | BytePositionInLine: C.'a' is an invalid start of a property name. Expected a '"'. Path: $ | LineNumber: L | BytePositionInLine: C.
System.Text.Json JsonDocument''' is an invalid start of a property name. Expected a '"'. LineNumber: L | BytePositionInLine: C.',' is an invalid start of a property name. Expected a '"'. LineNumber: L | BytePositionInLine: C.'/' is invalid after a value. Expected either ',', '}', or ']'. LineNumber: L | BytePositionInLine: C.'0xE2' is an invalid start of a property name. Expected a '"'. LineNumber: L | BytePositionInLine: C.'1' is an invalid start of a property name. Expected a '"'. LineNumber: L | BytePositionInLine: C.'a' is an invalid start of a property name. Expected a '"'. LineNumber: L | BytePositionInLine: C.
V8 JSON.parseExpected property name or '}' in JSON at position N (line L column C)
encoding/json Unmarshalinvalid character ',' looking for beginning of object key stringinvalid character '/' looking for beginning of object key stringinvalid character '1' looking for beginning of object key stringinvalid character '\'' looking for beginning of object key stringinvalid character 'a' looking for beginning of object key stringinvalid character 'â' looking for beginning of object key string
hjsonFound ',' where a key name was expected (check your syntax or use quotes if the key name includes {}[],: or whitespace) at line L,1
json-bigintBad string
json_decodeSyntax error
serde_json::from_strkey must be a string at line L column C
ujsonExpected object or valueKey name of object must be 'string' when decoding 'object'

← All JSON parser errors

Standards this registry is checked against

Only standards bodies and peer-reviewed venues are cited. Error strings on this site are observed by executing each parser; the standards above define what the parser is reacting to.