Back to Updates
DevTool Team

Unicode Decoding and Garbled Text: What \u Escapes Are and How to Restore Them

Got a wall of \u4f60\u597d or 你 and no idea what it says? Learn to tell Unicode escapes, code points, HTML entities, and URL encoding apart, restore them with code or a browser tool, and avoid the surrogate-pair trap.

First, identify which kind of garbled text you have

"Garbled text" is not one thing — it is four. Identify the shape before choosing the fix:

Shape Looks like What it is
Unicode escape \u4f60\u597d Escaped by code point; default output of JSON, JS source, some APIs
Code point form U+4F60 or 4f60 The character's number in the Unicode table itself
HTML entity 你 or 你 Character references in HTML, hex or decimal
URL encoding %E4%BD%A0%E5%A5%BD UTF-8 bytes percent-escaped one by one; one Chinese character = three %XX

\u4f60\u597d, 你, and %E4%BD%A0 all decode to the same character — the same text at three different layers. When they are nested (a URL parameter wrapping escaped JSON, say), peel one layer at a time.

Option 1: a browser tool, when you can't tell the shape

The Unicode converter supports converting between the four forms above, plus two capabilities that matter during debugging:

  1. Smart input detection — paste without knowing whether it is an escape, an entity, or percent encoding; the tool classifies it by shape.
  2. A per-character detail panel — code point, decimal, hex, UTF-8 bytes, and category for every character, so you can tell an encoding problem from a font problem at a glance.

Live counters show character and byte totals, and the conversion history is stored locally for flipping back and forth between two texts.

Option 2: restore with code

When you know the data's source and want the fix inside a script, it is two lines.

JavaScript — \u escapes inside JSON resolve automatically during JSON.parse:

JSON.parse('{"msg":"\\u4f60\\u597d"}').msg;  // "你好"

Escapes in a plain string render directly in console.log; to escape any character yourself, take charCodeAt(0).toString(16) and pad to four digits.

Python — the unicode_escape codec exists for exactly this:

s = r"\u4f60\u597d"
print(s.encode().decode("unicode_escape"))  # 你好

URL encoding is a different layer: urllib.parse.unquote("%E4%BD%A0"). The two often stack — decode the outer layer first, then the inner.

The reverse: when you need to encode, not decode

  • An API or config file accepts ASCII only, and plain Chinese text will not pass — escape the whole string to \u form.
  • To display special characters safely in HTML (<, &, invisible characters) — convert to HTML entities.
  • To build a URL parameter — percent-encode the text or the request breaks outright.
  • To answer "what IS this character" — convert to code point form and look up its category and name.

The tool swaps input and output with one click, so the reverse direction needs no second tool.

Emoji and surrogate pairs: the character-by-character trap

The code point of "😀" is U+1F600 — above U+FFFF. UTF-16 represents it as a surrogate pair: \ud83d\ude00. Consequences:

  • A naive decoder that walks character by character splits the pair into two "characters" and prints two replacement glyphs.
  • Code that counts code units reports one Emoji as two characters.
  • A truncation that lands inside a pair corrupts both halves.

The fastest credibility test for any Unicode tool: paste an Emoji. The converter on this site handles surrogate pairs correctly — characters above U+FFFF stay whole, and the statistics count them as single characters.

Frequently Asked Questions

What kind of encoding is a string like \u4f60\u597d?

Those are Unicode escape sequences: each \u is followed by four hex digits naming a character's code point. \u4f60\u597d decodes to the Chinese greeting for "hello". JSON, JavaScript source, and some APIs emit them by default; the text is still UTF-8 underneath, with non-ASCII characters written in escaped form.

Why does an Emoji turn into two characters after decoding?

Characters above U+FFFF (most Emoji) exceed the Basic Multilingual Plane, so UTF-16 represents them as a surrogate pair occupying two code units. Tools that decode character by character split one Emoji into two garbled units; tools that handle surrogate pairs merge them back correctly.

Are \u escapes and percent encoding (%E4%BD%A0) the same thing?

No. A \u escape names a character by code point; percent encoding is URL encoding, escaping UTF-8 bytes one by one — one Chinese character is usually three %XX groups. The two often appear in the same payload but sit at different layers, and the decode order matters.

How do I encode text into \u escapes in the other direction?

In Python, use "text".encode("unicode_escape"); on this site, switch the tool to its encode direction. JavaScript's JSON.stringify emits \u escapes for non-ASCII characters by default. Useful when an API accepts ASCII only or you want to reduce visible non-ASCII content.

Does decoding online send my text to a server?

The Unicode converter on this site runs entirely in your browser: input never leaves the device, and the conversion history is stored locally. Verify how other online tools handle data before pasting anything sensitive.