Truncated \u escape in a JSON string
A `\u` escape with fewer than four hex digits, typically where a string was cut mid-escape by a length limit.
The input
{"a": "\u12"}{"a": "\u0012"}How to fix it
Pad to four digits: `\u0012`, not `\u12`.
If a truncation limit cut the string, fix the truncation — cutting UTF-16 escapes in half corrupts data even when it happens to parse.
What each parser reports
Every message below was captured by running this exact input through the parser named. 21 of 21 parsers rejected it.
| Parser | Exact message |
|---|---|
| CPython json.loads CPython 3.12.3 | Invalid \uXXXX escape: line 1 column 9 (char 8)what this message means → |
| encoding/json Unmarshal Go go1.22.2 | invalid character '"' in \u hexadecimal character escapewhat this message means → |
| Gson Java 21.0.12 | \u12"} |
| Gson JsonParser (lenient off) Java 21.0.12 | java.lang.NumberFormatException: \u12"}what this message means → |
| hjson Node.js 22.22.2 | Bad \u char " at line 1,11 >>>"a": "\u12"} ...what this message means → |
| Jackson ObjectMapper Java 21.0.12 | Unexpected character ('"' (code 34)): expected a hex-digit for character escape sequencewhat this message means → |
| JavaScriptCore JSON.parse JavaScriptCore (Bun 1.4.1) | JSON Parse error: "\u12"}" is not a valid unicode escapewhat this message means → |
| json-bigint Node.js 22.22.2 | Bad string |
| JSON5 Node.js 22.22.2 | JSON5: invalid character '\"' at 1:12what this message means → |
| JSON::PP Perl 5.038002 | unexpected end of string while parsing JSON string, at character offset 12 (before "}")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 end while parsing Unicode escape sequence. Path 'a', line 1, position 9.what this message means → |
| Newtonsoft.Json JsonTextReader Newtonsoft.Json 13.0.3 on .NET 8.0.30 | Unexpected end while parsing Unicode escape sequence. Path 'a', line 1, position 9.what this message means → |
| orjson CPython 3.12.3 | invalid escaped sequence in string: line 1 column 8 (char 7)what this message means → |
| Ruby JSON.parse Ruby 3.2.3 | unexpected token at '{"a": "\u12"}' |
| serde_json::from_str Rust (serde_json 1.x) | invalid escape at line 1 column 13what this message means → |
| SpiderMonkey JSON.parse SpiderMonkey 115 | JSON.parse: bad Unicode escape at line 1 column 12 of the JSON datawhat this message means → |
| System.Text.Json Deserialize .NET 8.0.30 | '"' is not a hex digit following '\u' within a JSON string. The string should be correctly escaped. Path: $ | LineNumber: 0 | BytePositionInLine: 11.what this message means → |
| System.Text.Json JsonDocument .NET 8.0.30 | '"' is not a hex digit following '\u' within a JSON string. The string should be correctly escaped. LineNumber: 0 | BytePositionInLine: 11.what this message means → |
| ujson CPython 3.12.3 | Unexpected character in unicode escape sequence when decoding 'string'what this message means → |
| V8 JSON.parse Node.js 22.22.2 | Bad Unicode escape in JSON at position 11 (line 1 column 12)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 string begins and ends with a quotation mark. Any Unicode character may appear between them except the quotation mark, the reverse solidus, and the control characters U+0000 through U+001F, which the section requires to be escaped. It also fixes the escape set and the \uXXXX form. |
| Ecma International | A string is code points wrapped in quotation marks; the quotation mark, reverse solidus and U+0000–U+001F must be escaped. Table 3 fixes the escape sequences. |
| Unicode Consortium | Normatively referenced by RFC 8259 for the definition of a character. |
Other errors in this category
Literal newline inside a JSON string
A real line break between the quotes. JSON forbids unescaped control characters (U+0000 to U+001F) inside strings, and a newline i…
Literal tab inside a JSON string
A raw tab character inside string content. Like a newline, it is a control character and must be escaped.…
Invalid escape sequence in a JSON string
A backslash followed by a character JSON does not define. The complete set is `\" \\ \/ \b \f \n \r \t` and `\uXXXX`. Windows path…
Malformed \u escape in a JSON string
A `\u` not followed by exactly four hexadecimal digits.…
Lone surrogate in a JSON string
A high surrogate (`\uD800`–`\uDBFF`) with no following low surrogate. Characters outside the Basic Multilingual Plane — emoji, mos…
Raw NUL byte inside a JSON string
A U+0000 byte in string content, usually from a C string boundary, a fixed-width database column, or binary data that was treated …