Unicode Escape and Unescape
ED-14Paste text to convert non-ASCII characters to \uXXXX escapes, or paste escapes to turn them back into characters. Emoji become surrogate pairs or one \u{...} escape.
Runs in your browser. Nothing is uploaded.
Text or \u escapes
Result
How to use it
- Paste your text or your \u escapes into the input box.
- Press Escape or Unescape.
- Choose \uXXXX, which uses pairs for emoji, or \u{X...}, which uses one escape per character.
- Choose to escape only non-ASCII characters or every character, and pick the case of the hex digits.
- Copy the result.
The two escape styles
The \uXXXX style writes each UTF-16 code unit as four hex digits. A character beyond U+FFFF, such as an emoji, takes two escapes, a surrogate pair, so U+1F600 is \ud83d\ude00. This is the form used in JSON, Java and JavaScript. The \u{...} style writes one escape per character with any number of digits, as in \u{1f600}. JavaScript accepts it, but JSON does not. By default only non-ASCII characters are escaped, so readable ASCII text stays readable.
What Unescape reads
Unescape converts \uXXXX, \u{...} and the 8-digit \UXXXXXXXX form used by Python and C. A high surrogate followed by a low one is joined into a single character. A \u without enough digits, a value above U+10FFFF, or a surrogate escape that cannot form a character gives an error with its position. Text that is not an escape is left exactly as it is, and a doubled backslash is not touched.
Other escapes and backslashes
This tool does not convert \n, \t or \x41, and it does not escape backslashes in your original text. Text that already contains a \u sequence will be read as an escape when you unescape it. For complete string literal escaping, use the JSON Escape or JavaScript Escape tools on this site, which handle quotes and control characters too.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
Incomplete \u escape at line 1, column 3: \u needs 4 hex digits, or {...}. | A \u is followed by fewer than four hex digits. | Add the missing digits, or write the character with braces, such as \u{e9}. |
The escape \u{110000} at line 1, column 1 is above U+10FFFF, the largest Unicode code point. | The number inside the braces is larger than any Unicode character. | Use a value from 0 to 10FFFF. |
The escapes produce an unpaired surrogate (U+D83D). A high surrogate (D800 to DBFF) must be followed by a low one (DC00 to DFFF) to make a character. | A surrogate escape stands alone, so the result would not be valid text. | Add the matching second escape, or use one \u{...} escape for the whole character. |
Questions people ask
How do I convert text to Unicode escapes?
Paste the text and press Escape. Characters above U+007F become \uXXXX sequences, for example é becomes \u00e9. Switch to the \u{...} style if you want one escape per character, or to Every character to escape plain letters too.
How do I convert Unicode escapes to text?
Paste text containing \u00e9, \u{1F600} or \ud83d\ude00 and press Unescape. Each escape becomes its character, and surrogate pairs are joined into one emoji. Anything else in the text is left as it is.
What is a surrogate pair?
UTF-16 stores characters above U+FFFF as two 16-bit units, a high surrogate (D800 to DBFF) and a low surrogate (DC00 to DFFF). Written as escapes, they appear as two \u sequences, such as \ud83d\ude00 for the grinning face emoji.
What is the difference between \u00e9 and \u{e9}?
Both mean é. The first has exactly four hex digits and is accepted by JSON, Java and JavaScript. The second uses braces, can hold any number of digits and is valid in modern JavaScript, but not in JSON.
Why does the output have \ud83d\ude00 for one emoji?
In the \uXXXX style each escape is one UTF-16 code unit, and an emoji needs two of them. Choose the \u{X...} style to get a single escape, \u{1f600}, in environments that accept it.
Does it work for Python escapes?
Unescape also reads the 8-digit \UXXXXXXXX form that Python uses. For output, the \uXXXX style works in Python string literals when the character is in the Basic Multilingual Plane; for characters above U+FFFF such as emoji, the 8-digit \U form is the portable choice, because Python 3 does not join two \u surrogate escapes into one character.
About this tool
The default style writes each UTF-16 code unit as \uXXXX, so a character outside the Basic Multilingual Plane, such as an emoji, becomes two escapes (a surrogate pair), the form used in JSON, Java and JavaScript. The brace style writes one \u{...} escape per character, which JavaScript accepts but JSON does not. Unescape reads \uXXXX, \u{...} and the 8-digit \UXXXXXXXX form, and joins pairs back into one character. Text that is not an escape is left alone, and a doubled backslash is not touched. Backslashes in your original text are not escaped, so text that already contains \u sequences will read back as escapes. Other escapes such as \n are not converted; use the JSON or JavaScript escape tool.