Encoding
Unicode Escape
Encode and decode Unicode escape sequences — characters as \uXXXX and back.
A Unicode escape sequence (\uXXXX) writes a character as its code point instead of the character itself — so a string literal in code can contain any Unicode character while the source file itself stays plain ASCII.
How to use it
- Encode: paste text and every non-ASCII character gets replaced with its matching \uXXXX sequence.
- Decode: paste a string containing \uXXXX sequences to get plain, readable text back.
- Characters outside the Basic Multilingual Plane (most emoji) are encoded as a surrogate pair of two sequences.
Common uses
- Reading JSON or JS code where non-ASCII text was pre-escaped into \uXXXX for compatibility.
- Inserting a character that's not on the keyboard into code via an explicit Unicode escape.
- Debugging why a string with an emoji shows up as two odd characters — recognizing a surrogate pair.
Things to keep in mind
\uXXXX encodes exactly one 16-bit UTF-16 unit, not one visible character — characters outside the Basic Multilingual Plane (most emoji) need two such sequences together (a surrogate pair).
JSON only requires escaping for control characters and a few special characters — escaping every character as \uXXXX isn't required, though it is valid.
Article about this tool: Unicode Escape: what \uXXXX sequences mean
Frequently asked questions
What does a \uXXXX escape sequence represent?
It's a Unicode code point written as four hexadecimal digits, used in JSON, JavaScript strings, and similar formats to represent a character without typing it literally.
Why do some characters like emoji turn into two \u sequences?
Characters outside the Basic Multilingual Plane (astral characters, including most emoji) don't fit in a single 16-bit \uXXXX unit, so they're represented as a surrogate pair — two \uXXXX sequences that together encode one character.
What's the difference between "Non-ASCII" and "All characters" mode?
Non-ASCII only escapes characters outside the basic ASCII range, leaving plain letters, digits, and punctuation untouched. All characters escapes everything, including ASCII, which can be useful for spotting exact character content.
What happens if a surrogate pair gets split in half?
You get an invalid "orphan" code unit — a lone code without its match. Most parsers either reject the string with an error or render a replacement-character glyph, "�".
Can an emoji character be encoded with a single \uXXXX?
No, not if the emoji lies outside the Basic Multilingual Plane (and most modern emoji do) — it always needs a surrogate pair made of two \uXXXX sequences.