On this page

To read a Unicode escape in JSON, first separate the JSON source from the string produced by parsing it. A Unicode escape starts with a backslash and lowercase u, followed by four hexadecimal digits. Some characters use two such escapes together: the pair \uD834\uDD1E represents the G clef character π, identified as U+1D11E.
An extra backslash changes the interpretation. In JSON source, {"text":"\uD834\uDD1E"} produces the G clef as its text value. By comparison, {"text":"\\uD834\\uDD1E"} produces the literal text \uD834\uDD1E. The visible resemblance between that text and an escape sequence does not cause another decoding pass.
This guide uses explicit source and parsed-result labels throughout. Apply the same habit when working with FormatBits or reviewing a payload elsewhere: identify what you are looking at before interpreting its backslashes. Readable formatting, string interpretation, and downstream storage each raise different questions. The examples below help you inspect each stage without confusing notation with the value it represents.
Read a four-digit Unicode escape
A Unicode escape consists of a backslash, a lowercase u, and four hexadecimal digits. Read those parts together as one escape within the JSON string. For a concrete example, inspect the first escape in the G clef pair:
JSON source
{"text":"\uD834\uDD1E"}
The first escape is \uD834; the second is \uDD1E. Each has the required four-digit structure. Their combined result is explained in the next section; here, focus on recognizing the notation correctly.
Read each part in context
| Source part | How to read it |
|---|---|
\ |
The backslash begins this escape. |
u |
The lowercase letter introduces the Unicode escape. |
D834 |
These are the four hexadecimal digits in the first escape. |
\uD834 together |
This is the first escape in the illustrated pair. |
Hexadecimal letters within the four digits may be uppercase or lowercase. Keep that flexibility separate from the introductory u, which is lowercase. In this example, the letters within D834 and DD1E are uppercase; that does not change the requirement for the lowercase introductory letter.
Keep all four digit positions visible when copying an example. Shortening the notation changes the syntax you are asking a parser to read. For example, \uD83 has only three digits after the u, so it does not meet the four-digit form.
Check the complete input
If an escape seems incomplete, inspect the actual source before interpreting its intended result. A shortened display or an incomplete copy can prevent you from checking all four positions. Obtain the complete value and keep adjacent escapes together while reviewing it.
A useful reader question is: βAm I checking the notation written in the JSON source, or examining the text value after parsing?β The first task concerns the escape’s visible structure. The second concerns what the complete input produces. Keeping those tasks separate is especially helpful when a character is represented by a pair.
Read two escapes as one supplementary character
Some examples require you to read two Unicode escapes together. The G clef character π, identified as U+1D11E, can be represented by the surrogate-pair escapes \uD834\uDD1E.
JSON source
{"text":"\uD834\uDD1E"}
Parsed text value
π
Here, two four-digit escapes work together to represent one supplementary character. Each escape retains the visible structure introduced earlier: a backslash, lowercase u, and four hexadecimal digits. For this character, the paired representation is the complete spelling to inspect. Reading either half independently would not explain the illustrated result.
Follow the pair through the example
| What you inspect | What the example contains |
|---|---|
| First escape in the source | \uD834 |
| Second escape in the source | \uDD1E |
| Complete paired spelling | \uD834\uDD1E |
| Resulting character | π, U+1D11E |
The important reading habit is to keep the two escapes together when explaining this result. Treating each visible escape as a separate final character would misdescribe the example. Likewise, counting the characters occupied by the source notation does not tell you how many resulting characters this pair represents.
Preserve the complete example when troubleshooting
If this example behaves unexpectedly in a workflow, retain the complete source spelling and inspect the parsed value separately. Ask whether both escapes reached the receiving component together and whether its handling supports the intended pair. Avoid editing one half independently while trying to make the input more readable.
For a different pair, verify the intended character and the receiving component’s requirements instead of guessing from visual similarity. A useful question is: βDoes the parsed value contain the intended G clef, and what exact source did this component receive?β That keeps the investigation tied to a specific input and result.
Recognize a literal backslash
Two consecutive backslashes inside a JSON string encode one backslash in the parsed value. This changes how you should read text that resembles a Unicode escape.
Compare the following inputs carefully. In the second source, each escape-like portion begins with an escaped backslash.
JSON source: paired Unicode escapes
{"text":"\uD834\uDD1E"}
Parsed text value
π
JSON source: escaped backslashes followed by text
{"text":"\\uD834\\uDD1E"}
Parsed text value
\uD834\uDD1E
In the second input, each pair of source backslashes produces one literal backslash. The uD834 and uDD1E portions follow those backslashes as text. The resulting value contains twelve literal characters, including two backslashes. It does not contain the G clef shown in the first result.
Do not assume another decoding pass
Parsing the second input does not automatically reinterpret the resulting backslashes and following text as new Unicode escapes. The result of this parse is the literal text shown above. If a workflow later interprets that text again, investigate that as a separate operation.
This distinction is useful when a report says that an escape βwas not decoded.β First establish the intended value. If the sender intended the G clef, compare the received source with the first example. If the sender intended the visible text \uD834\uDD1E, the second example expresses that intention.
Ask about the representation layer
Before adding or removing backslashes, ask: βIs this raw JSON, a parsed string, or a representation embedded in another string?β Obtain the exact input at the boundary you are debugging, then label its result separately. Counting backslashes in an unexplained display is less useful than comparing a known source with the value it produces.
Use a small example like these when communicating the issue. State the intended result alongside the source so a reviewer can distinguish a character from text describing its escape spelling.
Compare source spelling with parsed values
Different JSON source spellings can produce the same text value. These two inputs both produce the G clef character π:
JSON source: character written directly
{"text":"π"}
JSON source: character written as paired escapes
{"text":"\uD834\uDD1E"}
Parsed text value for both inputs
π
This comparison answers a common inspection question: a visible change in source spelling does not, by itself, establish a change in the parsed value. To assess what happened, compare the relevant inputs and results explicitly.
Keep a source-and-result comparison
| JSON source | Parsed text value | Relationship to the other examples |
|---|---|---|
{"text":"π"} |
π |
Same value as the next row. |
{"text":"\uD834\uDD1E"} |
π |
Alternative source spelling for the G clef. |
{"text":"\\uD834\\uDD1E"} |
Literal text \uD834\uDD1E |
A different value from the G clef. |
The table separates two useful comparisons. Comparing source text tells you whether the spelling changed. Comparing parsed values tells you whether the resulting text changed. Choose the comparison that matches your task, and retain both when the distinction matters.
Inspect a formatter’s display deliberately
When using a formatting tool, ask whether the displayed output preserves escape spelling or shows equivalent characters. Do not infer that behavior from indentation or visual neatness. For a particular tool or operation, check its documented behavior and inspect a small input whose intended result is clear.
For a FormatBits workflow, the examples above provide a compact inspection set. Record the input, the displayed output, and the parsed text value in separate fields or notes. This helps you explain a result without assuming that every view presents the same representation.
If a reviewer asks whether two payloads are βthe same,β clarify what they need to compare. Exact source spelling and the resulting text value are different questions. For example, a review concerned with preserving source notation needs the original escape spelling, while a review concerned with the intended text needs the parsed result.
Investigate syntax and downstream restrictions
Start with the escape’s syntax, then investigate the requirements of the component receiving it. An incomplete escape and a downstream Unicode restriction call for different checks.
For the syntax check, return to the visible form: a backslash, lowercase u, and four hexadecimal digits. If the source contains \uD83, it is missing one of those digits. Resolve that concrete problem before using the input to investigate storage or processing behavior.
JSON strings also require escaping for quotation marks, backslashes, and control characters U+0000 through U+001F. When examining a rejected input, inspect the complete string rather than focusing exclusively on the Unicode escape that first drew attention.
Use PostgreSQL as a focused downstream check
When a workflow uses PostgreSQL’s json or jsonb type, check the requirements of the selected type and operation. PostgreSQL’s jsonb handling converts valid Unicode escapes to characters, including combining surrogate pairs. That behavior makes the distinction between source spelling and the resulting character relevant when reviewing a database workflow.
For the actual operation, verify the database’s Unicode restrictions and the behavior of the selected type. Keep the precise input and error available so the investigation addresses the case that occurred. The conversion behavior described here does not establish every acceptance rule for either type or every later operation.
Ask questions that narrow the failure
- What exact JSON source reached the database operation?
- Is the operation using
jsonorjsonb? - Does the input contain a complete escape, a paired escape, or an escaped literal backslash?
- Does the error arise when accepting the input or during a later operation?
- What do the applicable database requirements say about that input?
These questions help distinguish malformed source from implementation-specific handling without guessing at a restriction. If another component accepts the text, retain that observation alongside the database result; acceptance at one boundary does not answer what happened at another.
For a useful issue report, include a minimal source example, the intended parsed value, the receiving operation, and the exact error. For the G clef example, explicitly state whether the intended value is π or the literal text \uD834\uDD1E. That gives a reviewer enough information to check syntax, intended meaning, and downstream requirements separately.