Skip to content
AZ Tools

Unicode Escape Converter

Encode text to \uXXXX, U+XXXX or HTML entities — and decode any of those back to text. Handles emoji and astral characters.

Output

How to use

  1. Pick a direction: Text → Escapes or Escapes → Text.
  2. For encoding, choose the format and whether to escape every character or just non-ASCII.
  3. Copy the result from the output box.

About this tool

Show

Turns text into escape sequences and back. Encoding covers JavaScript and JSON \uXXXX, the U+XXXX notation used in specifications and bug reports, and HTML entities in both hex and decimal — keeping plain ASCII readable, or escaping every character if the destination is fussy. Decoding recognises all of those at once, plus \u{...}, \xXX and bare U+, so a log line with three different escape styles mixed together comes back as the text it was.

The reason \uXXXX needs company is that it is a UTF-16 escape, and UTF-16 only has room for four hex digits. Characters above U+FFFF have to be written as a surrogate pair: a grinning face is U+1F600, and in a JavaScript string it is \uD83D\uDE00, two escapes that mean one character. The newer \u{1F600} says the same thing in one piece, and the HTML forms are 😀 and 😀. All four are the same character; only the first exposes the machinery.

That machinery is worth understanding because it leaks. The values D800 through DFFF are reserved for the two halves of a pair and are not characters in their own right, so a lone surrogate — produced by slicing a string at the wrong offset, or by a truncation that counted UTF-16 units — is not valid text and cannot be encoded to UTF-8 at all. It survives inside a JavaScript string and then fails at the moment something tries to write it to a file or a network socket, which is a long way from where it was created.

The practical use is getting non-ASCII through a channel that cannot be trusted with it. A build pipeline that mangles UTF-8, a config format with an uncertain encoding, a system that accepts only ASCII bytes: escaping every non-ASCII character makes the data survive intact and stay diff-able, at the cost of being unreadable to a human. The reverse is more common day to day — pasting an escaped string out of a log or a stack trace to find out what it actually said. Everything runs in your browser.

Frequently asked questions

How are emoji handled?

In \uXXXX form, characters above U+FFFF (like 😀) are written as a surrogate pair of two \u escapes; U+ and HTML forms use the single code point (e.g. U+1F600, 😀). Decoding reassembles them correctly either way.

What can the decoder read?

It auto-detects \uXXXX, \u{XXXXX}, \xXX, U+XXXX, &#xHEX; and &#DEC; — all in the same input, so mixed escapes still decode.

What does 'escape all characters' do?

Off, only non-ASCII characters are escaped and plain ASCII stays readable. On, every character is converted to an escape, which is handy for fully obfuscated or strictly-ASCII output.

Is my text uploaded?

No. Encoding and decoding happen entirely in your browser; nothing is sent to a server.

Why did U+00E9ABC decode to the wrong character?

The U+ pattern accepts one to six hex digits and takes as many as it can, so it swallowed 00E9AB and left a stray C — you get U+E9AB, a CJK ideograph, instead of é followed by ABC. Any U+ notation immediately followed by more hex-looking letters has the same problem. Put a space or a non-hex character after the code point, or use the é form, which is terminated by its semicolon and cannot over-read.

Can the decoder tell a real escape from an escaped backslash?

No. Decoding is a sequence of pattern replacements with no notion of escaping the escape, so the two characters backslash-backslash followed by u0041 — which in most languages means a literal backslash then the text u0041 — comes back as backslash A. If your input is a source-code string that already doubles its backslashes, halve them before pasting. Escapes that reach here through an ordinary copy from rendered text are unaffected.

Guides on this topic

Related tools