Why Does My JSON Look Garbled? Unicode Encoding Fixes
2024-12-01
Garbled Chinese or broken emoji after pasting an API response? The JSON is often fine—RFC 8259 requires UTF-8 for cross-system transport; the bug is usually on the decode side.
JSON and Unicode
Strings may contain raw Unicode or \uXXXX escapes—both decode to the same characters.
RFC 8259 requires UTF-8 when JSON is exchanged between systems; save local files as UTF-8 too.
{
"greeting": "Hello",
"escaped": "\u0048\u0065\u006c\u006c\u006f",
"emoji": "🎉"
}Common symptoms
Question marks or �: decoded as Latin-1/GBK instead of UTF-8. File fine in DB but broken on export: wrong export charset.
\u escapes
Some serializers emit ASCII-safe escapes; parsed data is still correct Unicode. Fix transport encoding, not the escapes themselves.
HTTP Content-Type
application/json has no IANA charset parameter; bytes should still be UTF-8 per RFC 8259.
Fix wrong server headers rather than client-side workarounds.
BOM pitfalls
RFC 8259 forbids sending a BOM on networked JSON; parsers may ignore one but you should not rely on it.
Save .json files as UTF-8 without BOM; watch for hidden characters when copying from Notepad on Windows.
Checklist
Verify bytes are UTF-8, editor encoding matches, online parse looks correct, then fix the consumer in the chain.