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 end of string while parsing JSON string
JSON::PP · Perl 5.038002

unexpected end of string while parsing JSON string, at character offset N (before "…")

This message comes from JSON::PP on Perl 5.038002. In this registry it is produced by 13 distinct mistakes. Positions in the real message vary with your input; the causes do not.

What produces this message

Malformed \u escape in a JSON string

Input
{"a": "\uZZZZ"}

Exact message: unexpected end of string while parsing JSON string, at character offset 10 (before "ZZZ"}")

Fix: Supply four hex digits, or escape the backslash if you meant a literal `\u`.

/* */ comments are not valid JSON

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

Exact message: unexpected end of string while parsing JSON string, at character offset 3 (before "* note */ "a": 1 }")

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 end of string while parsing JSON string, at character offset 2 (before "}")

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 end of string while parsing JSON string, at character offset 2 (before ": 1, b: 'two', c: [3...")

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 end of string while parsing JSON string, at character offset 5 (before "/ note\x{a} "a": 1\x{a}...")

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 end of string while parsing JSON string, at character offset 2 (before ": "a"}")

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

Python dict repr passed off as JSON

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

Exact message: unexpected end of string while parsing JSON string, at character offset 2 (before "a': 1, 'b': [1, 2]}")

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

Truncated \u escape in a JSON string

Input
{"a": "\u12"}

Exact message: unexpected end of string while parsing JSON string, at character offset 12 (before "}")

Fix: Pad to four digits: `\u0012`, not `\u12`.

Single-quoted strings in JSON

Input
{'a': 1}

Exact message: unexpected end of string while parsing JSON string, at character offset 2 (before "a': 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 end of string while parsing JSON string, at character offset 2 (before "\x{80}\x{9c}a\x{e2}\x{80}...")

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

Trailing comma in a JSON object

Input
{"a": 1,}

Exact message: unexpected end of string while parsing JSON string, at character offset 9 (before "(end of string)")

Fix: Delete the comma before the closing brace.

Unquoted object key in JSON

Input
{a: 1}

Exact message: unexpected end of string while parsing JSON string, at character offset 2 (before ": 1}")

Fix: Wrap every key in double quotes.

Unterminated string in JSON

Input
{"a": "hello}

Exact message: unexpected end of string while parsing JSON string, at character offset 13 (before "(end of string)")

Fix: Escape internal double quotes as `\"`, and check that every string has a matching closing quote.

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)Invalid \uXXXX escape: line L column C (char N)Unterminated string starting at: line L column C (char N)
GsonExpected name at line L column C path $…Unterminated string at line L column C path $…\u12"}\uZZZZ
Gson JsonParser (lenient off)Expected name at line L column C path $…Unterminated string at line L column C path $…java.lang.NumberFormatException: \u12"}java.lang.NumberFormatException: \uZZZZ
JSON5JSON5: invalid character ',' at 1:2JSON5: invalid character '1' at 1:2JSON5: invalid character 'Z' at 1:10JSON5: invalid character '\"' at 1:12JSON5: invalid character '“' at 1:2JSON5: invalid end of input at 1:14
Jackson ObjectMapperUnexpected character ('"' (code 34)): expected a hex-digit for character escape sequenceUnexpected 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 ('Z' (code 90)): expected a hex-digit for character escape sequenceUnexpected character ('a' (code 97)): was expecting double-quote to start field nameUnexpected character ('}' (code 125)): was expecting double-quote to start field nameUnexpected end-of-input: was expecting closing quote for a string value
JavaScriptCore JSON.parseJSON Parse error: "\u12"}" is not a valid unicode escapeJSON Parse error: "\uZZZZ" is not a valid unicode escapeJSON Parse error: Expected '}'JSON Parse error: Property name must be a string literalJSON Parse error: Single quotes (') are not allowed in JSONJSON Parse error: Unrecognized token '/'JSON Parse error: Unrecognized token '“'JSON Parse error: Unterminated string
Newtonsoft.Json JsonConvertInvalid Unicode escape sequence: \uZZZZ. Path 'a', line L, position N.Invalid property identifier character: ,. Path '', line L, position N.Invalid property identifier character: “. Path '', line L, position N.Unexpected end while parsing Unicode escape sequence. Path 'a', line L, position N.Unterminated string. Expected delimiter: ". Path 'a', line L, position N.
Newtonsoft.Json JsonTextReaderInvalid Unicode escape sequence: \uZZZZ. Path 'a', line L, position N.Invalid property identifier character: ,. Path '', line L, position N.Invalid property identifier character: “. Path '', line L, position N.Unexpected end while parsing Unicode escape sequence. Path 'a', line L, position N.Unterminated string. Expected delimiter: ". Path 'a', line L, position N.
Ruby JSON.parseunexpected token at '…'
SpiderMonkey JSON.parseJSON.parse: bad Unicode escape at line L column C of the JSON dataJSON.parse: expected double-quoted property name at line L column C of the JSON dataJSON.parse: expected property name or '}' at line L column C of the JSON dataJSON.parse: unterminated string at line L column C of the JSON data
System.Text.Json Deserialize'"' is not a hex digit following '\u' within a JSON string. The string should be correctly escaped. Path: $ | LineNumber: L | BytePositionInLine: C.''' 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.'Z' is not a hex digit following '\u' within a JSON string. The string should be correctly escaped. Path: $ | LineNumber: L | BytePositionInLine: C.'a' is an invalid start of a property name. Expected a '"'. Path: $ | LineNumber: L | BytePositionInLine: C.Expected end of string, but instead reached end of data. Path: $ | LineNumber: L | BytePositionInLine: C.The JSON object contains a trailing comma at the end which is not supported in this mode. Change the reader options. Path: $ | LineNumber: L | BytePositionInLine: C.
System.Text.Json JsonDocument'"' is not a hex digit following '\u' within a JSON string. The string should be correctly escaped. LineNumber: L | BytePositionInLine: C.''' 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.'Z' is not a hex digit following '\u' within a JSON string. The string should be correctly escaped. LineNumber: L | BytePositionInLine: C.'a' is an invalid start of a property name. Expected a '"'. LineNumber: L | BytePositionInLine: C.Expected end of string, but instead reached end of data. LineNumber: L | BytePositionInLine: C.The JSON object contains a trailing comma at the end which is not supported in this mode. Change the reader options. LineNumber: L | BytePositionInLine: C.
V8 JSON.parseBad Unicode escape in JSON at position N (line L column C)Expected double-quoted property name in JSON at position N (line L column C)Expected property name or '}' in JSON at position N (line L column C)Unterminated string in JSON at position N (line L column C)
encoding/json Unmarshalinvalid character '"' in \u hexadecimal character escapeinvalid 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 'Z' in \u hexadecimal character escapeinvalid character '\'' looking for beginning of object key stringinvalid character 'a' looking for beginning of object key stringinvalid character '}' looking for beginning of object key stringinvalid character 'â' looking for beginning of object key stringunexpected end of JSON input
hjsonBad \u char " at line L,11Bad \u char Z at line L,9Bad string at line L,13Found ',' 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_decodeControl character error, possibly incorrectly encodedSyntax error
orjsoninvalid escaped sequence in string: line L column C (char N)trailing comma is not allowed: line L column C (char N)unexpected character, expected a string key: line L column C (char N)unexpected end of data: line L column C (char N)
serde_json::from_strEOF while parsing a string at line L column Cinvalid escape at line L column Ckey must be a string at line L column Ctrailing comma at line L column C
ujsonExpected object or valueKey name of object must be 'string' when decoding 'object'Unexpected character in found when decoding object valueUnexpected character in unicode escape sequence when decoding 'string'Unmatched '"' when decoding 'string'

← 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.