Runs 100% in your browser — nothing is uploaded
Encoding & Decoding

Unicode Escape / Unescape

Escape text to \uXXXX, \UXXXXXXXX, or HTML entity form, and unescape it back to readable characters.

Unicode Escape / Unescape
Client-side

About this tool

The Unicode Escape / Unescape tool converts readable text into escaped Unicode codepoint notation, and reverses escaped sequences back into their original characters. This is essential when working with JSON strings, JavaScript/Java/Python source containing non-ASCII literals, log files that escape non-printable characters, or debugging mangled encoding.

Three output formats are supported: the common \uXXXX form (4 hex digits, used by JSON and most languages — astral characters like emoji are automatically split into a UTF-16 surrogate pair), the \UXXXXXXXX form (8 hex digits, used by Python and C-family languages for any codepoint without surrogate pairs), and the HTML numeric entity form (&#xXXXX;).

An "escape only non-ASCII" toggle lets you leave plain ASCII characters untouched and only escape the characters that would actually cause encoding trouble. Turn it off to escape every character, including ASCII.

Unescaping auto-detects and handles \uXXXX sequences (including merging valid surrogate pairs back into a single emoji or astral character), \UXXXXXXXX sequences, and HTML entities in the same input. Everything runs locally — no server round-trip.

FAQ

What is the difference between \uXXXX and \UXXXXXXXX?
\uXXXX uses exactly 4 hex digits and covers the Basic Multilingual Plane; characters beyond that must be split into a UTF-16 surrogate pair. \UXXXXXXXX uses 8 hex digits and represents any codepoint in a single escape.
Why does my emoji turn into two \u sequences instead of one?
Emoji above codepoint U+FFFF cannot be represented in a single 16-bit \uXXXX unit. JavaScript strings represent them as a UTF-16 surrogate pair — select \UXXXXXXXX format if you want a single non-paired escape.
What does "escape only non-ASCII" mean?
When enabled, characters with codepoints below 128 are left as literal characters, and only non-ASCII characters are escaped, keeping output readable.
Can I unescape a mix of formats in one input?
Yes. The unescape function scans for and converts \uXXXX, \UXXXXXXXX, and HTML entity sequences in the same pass.
Is this the same as JavaScript's JSON.stringify escaping?
Very close — JSON.stringify escapes non-ASCII using the same surrogate-pair convention when needed. This tool gives explicit control over format and whether to escape ASCII.