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 / Malformed \u escape in a JSON string
JSON error registry · String content

Malformed \u escape in a JSON string

A `\u` not followed by exactly four hexadecimal digits.

The input

Fails to parse
{"a": "\uZZZZ"}
Parses correctly
{"a": "\u0041"}

Open this broken input in the formatter →

How to fix it

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

A common origin is double-escaping: text that already contained `\u0041` gets escaped again and loses its digits.

What each parser reports

Every message below was captured by running this exact input through the parser named. 20 of 21 parsers rejected it; 1 accepted 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 'Z' in \u hexadecimal character escape
what this message means →
Gson
Java 21.0.12
\uZZZZ
Gson JsonParser (lenient off)
Java 21.0.12
java.lang.NumberFormatException: \uZZZZ
what this message means →
hjson
Node.js 22.22.2
Bad \u char Z at line 1,9 >>>"a": "\uZZZZ"} ...
what this message means →
Jackson ObjectMapper
Java 21.0.12
Unexpected character ('Z' (code 90)): expected a hex-digit for character escape sequence
what this message means →
JavaScriptCore JSON.parse
JavaScriptCore (Bun 1.4.1)
JSON Parse error: "\uZZZZ" is not a valid unicode escape
what this message means →
json-bigint
Node.js 22.22.2
accepted — no error
JSON5
Node.js 22.22.2
JSON5: invalid character 'Z' at 1:10
what this message means →
JSON::PP
Perl 5.038002
unexpected end of string while parsing JSON string, at character offset 10 (before "ZZZ"}")
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
Invalid Unicode escape sequence: \uZZZZ. Path 'a', line 1, position 9.
what this message means →
Newtonsoft.Json JsonTextReader
Newtonsoft.Json 13.0.3 on .NET 8.0.30
Invalid Unicode escape sequence: \uZZZZ. 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": "\uZZZZ"}'
serde_json::from_str
Rust (serde_json 1.x)
invalid escape at line 1 column 13
what this message means →
SpiderMonkey JSON.parse
SpiderMonkey 115
JSON.parse: bad Unicode escape at line 1 column 10 of the JSON data
what this message means →
System.Text.Json Deserialize
.NET 8.0.30
'Z' is not a hex digit following '\u' within a JSON string. The string should be correctly escaped. Path: $ | LineNumber: 0 | BytePositionInLine: 9.
what this message means →
System.Text.Json JsonDocument
.NET 8.0.30
'Z' is not a hex digit following '\u' within a JSON string. The string should be correctly escaped. LineNumber: 0 | BytePositionInLine: 9.
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 9 (line 1 column 10)
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…

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

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 …

← All JSON parser errors