Unicode Escape Encoder & Decoder

Type in either box to turn text into \uXXXX, \u{…}, &#x…;, or U+XXXX, or decode any mix of Unicode escapes back into text.

Output format

How to Use

  1. Type or paste text into the top box and the bottom box immediately shows the Unicode escapes in your chosen format.
  2. Pick from four output formats: \uXXXX (used in JavaScript, JSON, and Java), \u{…} (ES6, Rust, Ruby), &#x…; (HTML hex numeric entities), and U+XXXX (standard Unicode code point notation).
  3. With \uXXXX, characters outside the Basic Multilingual Plane (above U+FFFF), such as emoji, are written as a UTF-16 surrogate pair—for example, 🍤 becomes \uD83C\uDF64. The other three formats write a single code point (\u{1F364}, 🍤, U+1F364).
  4. Paste escapes into the bottom box to decode them in the top box. You don't have to pick a format first: all four formats are recognized automatically, even mixed together in the same string, while ordinary text is kept as is.
  5. If there's a lone surrogate, a code point above U+10FFFF, or a cut-off escape, the box with the problem shows the character position and reason while the other box keeps its last good result. “Select the problem” highlights that part for you.
  6. “Swap” moves the result into the box you typed in. “Clear” empties both boxes.

Unicode Escape Examples: Input and Output

Type text into the top box and pick an output format. The bottom box shows the escapes right away. Here is the same text, é🍤, in all four formats.

Output format Result Commonly used in
\uXXXX \u00E9\uD83C\uDF64 JavaScript, JSON, Java
\u{…} \u{E9}\u{1F364} ES6, Rust, Ruby
&#x…; é🍤 HTML and XML
U+XXXX U+00E9 U+1F364 Unicode tables and specs

To decode, paste escapes into the bottom box. You don’t need to choose a format first. For example, \u00E9 \u{1F364} U+4E2D is decoded into é 🍤 中, even though it mixes three formats.

Why an Emoji Becomes Two \uXXXX Escapes

A \uXXXX escape has exactly four hex digits, so it can only name characters up to U+FFFF. The 🍤 in the example is U+1F364, which is above that. In \uXXXX form it is written as a surrogate pair, \uD83C\uDF64: a high part followed by a low part. The other three formats have no four-digit limit, so each of them writes the single code point.

If a pair is broken, such as a high part with nothing after it, the tool tells you where, and the other box keeps its last good result.

FAQ

How do I convert text to \uXXXX?

Type or paste your text into the top box. The default output format is \uXXXX, so é appears as \u00E9 right away. To go back, paste \uXXXX sequences into the bottom box and the text appears above. Examples are further down the page.

Is my text uploaded or saved?

No. The conversion runs in your browser and nothing you type is sent to a server. Only your chosen output format is saved on this device, never the text.

What is a Unicode escape and when is it used?

A Unicode escape writes any character using only ASCII hex digits for its code point. For example, é is U+00E9, written as \u00E9 in a JavaScript or JSON string. It's handy when a file, config, or terminal shouldn't contain raw non-ASCII characters, or when an API or log gives you \uXXXX sequences that you want to read as normal text.

Are Unicode escapes a form of encryption?

No. Unicode escapes are an encoding: they simply write each character by its number in the public Unicode standard, with no key, so anyone can turn them back into the original text. They don't hide anything. To protect content, use real encryption.

What's the difference between the four output formats?

\uXXXX is the most widely supported and the only form allowed in strict JSON; it also works in JavaScript, Java, C#, and Python strings. \u{…} is the modern ES6 form that doesn't split characters above U+FFFF into surrogate pairs, and is also used in Rust and Ruby. &#x…; is an HTML and XML hex character reference. U+XXXX is the notation used in the Unicode Standard, font tables, and specs, with code points separated by spaces.

Why does an emoji become two escapes in \uXXXX but only one in the other formats?

\uXXXX always has four hex digits, so on its own it only reaches U+FFFF (the Basic Multilingual Plane). Most emoji live above U+10000, which UTF-16 represents as a high surrogate (D800–DBFF) followed by a low surrogate (DC00–DFFF), called a surrogate pair. \u{…}, &#x…;, and U+XXXX aren't limited to four digits, so they write the single code point directly. Multi-character emoji sequences such as family emoji joined with U+200D still list each underlying code point in every format.

What do “unpaired surrogate” and “above U+10FFFF” mean when decoding?

Code points D800 through DFFF are reserved for UTF-16 surrogate pairs and aren't characters on their own. In \uXXXX, a high surrogate (D800–DBFF) must be followed immediately by a low surrogate (DC00–DFFF); if its partner is missing, the order is flipped, or D800–DFFF appears in a single-code-point format, the tool reports an unpaired surrogate. The highest code point in Unicode is U+10FFFF, so any larger number is out of range.