JSON guide · 2 min read
JSON Unicode, UTF-8 and Escaped Characters
Understand Unicode text in JSON, UTF-8 transport, escaped characters and the encoding problems that create corrupted payloads.
JSON strings can contain Unicode text directly
JSON can represent names and text from languages around the world. Ordinary non-ASCII characters do not need to be replaced by Unicode escape notation merely to make the document valid.
{"city":"Kolkata","greeting":"নমস্কার","symbol":"✓"}UTF-8 is the normal web transport encoding
Modern JSON exchanged over HTTP is ordinarily UTF-8. Garbled text often appears when a producer writes bytes using one encoding and a consumer decodes them using another.
Literal characters and escapes can represent the same text
A JSON string can contain a literal character or a Unicode escape sequence representing that character. After parsing, both can produce the same string value. A formatter may choose a different source representation without changing the value.
Literal:
{"mark":"✓"}
Escaped source form:
{"mark":"\u2713"}Supplementary characters can use surrogate-pair escapes
Characters outside the basic multilingual plane can be represented using paired UTF-16 surrogate escapes in JSON source. Application code should normally let its JSON library handle those details rather than constructing the pair manually.
Control characters inside strings need escaping
Literal control characters such as newlines and tabs cannot appear unescaped inside a quoted JSON string. Newlines between JSON tokens are fine; a newline that belongs to a string value must use the appropriate escape sequence.
Debug corruption at the encoding boundary
If international text is corrupted, check the original bytes, file encoding and HTTP decoding assumptions before repeatedly re-encoding the damaged string. Once text is misdecoded, additional conversions often make diagnosis harder.
- Confirm source-file encoding.
- Use UTF-8 consistently across producer and consumer.
- Inspect raw bytes when mojibake appears.
- Do not assume Unicode escaping is required for non-English text.
Common questions
Frequently asked questions
Does JSON support non-English characters directly?
Yes. JSON strings are Unicode and can contain international text directly when transport encoding is handled correctly.
Is Unicode escape notation required?
No. It is an alternative source representation; literal characters and valid escapes can decode to the same string value.
Why does my JSON show garbled international text?
The producer and consumer may disagree about character encoding. Check the source bytes and decoding assumptions first.