piapia123
en

Unicode Escape & Unescape

Encoding & Crypto

Everything runs locally in your browser — nothing is uploaded

Input
Output

Convert non-ASCII characters to escape sequences, and back again. Each form has its place: \uXXXX for JavaScript, Java, C# and .properties files; \xXX for raw UTF-8 bytes as written in Python, C and PHP (\xE4\xB8\xAD is one CJK character); &#xXXXX; for HTML numeric references. Emoji come out as the standard surrogate pair \uD83D\uDE00 rather than \u{1F600}, which Java and .properties files do not understand. Backslashes and ampersands are escaped too, so that decoding is an exact inverse of encoding — otherwise a literal \u0041 sitting in your text would be read back as the letter A.

Features

  • Both directions: non-ASCII text and emoji ⇄ escape sequences
  • Three forms: \uXXXX (JS / Java), \xXX (UTF-8 bytes) and &#xXXXX; (HTML numeric references)
  • Decoding recognises all three forms at once, even when they are mixed in one string
  • Emoji written as the standard surrogate pair, accepted by Java and .properties files
  • Backslashes and ampersands escaped so that decode(encode(x)) === x holds exactly
  • Also understands the \u{1F600} and \U0001F600 code point notations
  • Unrecognised escapes are passed through instead of throwing

How to use

  1. Pick the direction: encode or decode
  2. Choose the escape form you need when encoding
  3. Paste your content — the result appears instantly
  4. Click Copy to take the result

FAQ

Why does a CJK character become three bytes in the \xXX form?
Because \xXX stands for a single byte, and CJK characters do not fit in one. They are encoded as UTF-8 first: the character U+4E2D is E4 B8 AD, written \xE4\xB8\xAD. That is exactly how Python bytes objects and C string literals look. Decoding follows the same rule, so whether it round-trips depends on those bytes forming valid UTF-8.
Why did \u0026 and \u005C appear in my output?
To make decoding an exact inverse of encoding. Your text may already contain something like \u0041 or 中, and without escaping the backslash and the ampersand the decoder would treat them as real escape sequences and silently produce the wrong result. The escaped output is still restored correctly by anything that understands \u escapes: JavaScript, Java and .properties files.
Why do emoji become two \u escapes instead of one?
U+1F600 is outside the Basic Multilingual Plane, so in UTF-16 it must be written as the surrogate pair \uD83D\uDE00. Java and .properties files only accept that form, never \u{1F600}, so encoding emits pairs; decoding joins adjacent pairs back into a single character.
Does decoding fail on a broken escape?
No. All three forms are recognised at once, and anything unrecognised — a half-written \uD8, an out-of-range �, or an escape from another language such as \n — is left exactly as it was. Real-world text mixes in unrelated escapes all the time, and failing the whole input would cost you the parts that were perfectly fine.

Related tools