Supplementary Unicode scalars do not fit in one four-digit \u escape. JSON represents them with the two UTF-16 code units of one valid surrogate pair.

Valid pair

Enter `"caf\u00e9 \ud83d\ude00"`, choose Unescape once and Quoted JSON string. The output is `café 😀`. The first \u escape represents é in the Basic Multilingual Plane. The adjacent high-surrogate `\ud83d` and low-surrogate `\ude00` escapes combine into the single scalar U+1F600. EscapeJSON reports three consumed escape sequences but the emoji counts as one Unicode code point in the result.

Invalid single surrogate

Now try `"\ud83d"` or `"\ude00"`. EscapeJSON returns UNPAIRED_SURROGATE and no partial output. RFC 8259 notes that isolated surrogate escapes can produce unpredictable behavior between implementations, including different string lengths or runtime failures. Rejecting them preserves an interoperable Unicode result instead of silently inserting a replacement character or passing through a malformed UTF-16 value.

Verify the destination and layer count

Compare the result with the producer and destination contracts. JSON escaping protects only one JSON string grammar; it does not sanitize HTML, SQL, JavaScript, shell input or another parser. Decode one reviewed layer at a time, reject malformed Unicode, and keep a known fixture for important integrations.