Unicode Escape

Convert non-ASCII characters into \uXXXX escape sequences for source code and config files.

Text
Escaped
Runs locally in your browser

About the Unicode Escape

Some file formats and older tools accept only ASCII, so non-ASCII characters have to be written as escape sequences. This tool converts each character above ASCII into a \uXXXX sequence, the form used in JavaScript, Java, JSON and Java properties files. Characters outside the Basic Multilingual Plane, such as emoji, are written as a surrogate pair of two \u escapes, which is how those languages represent them.

Surrogate pairs are the detail worth understanding. A code point above U+FFFF cannot fit in four hex digits, so it is written as a high surrogate in the D800 to DBFF range followed by a low surrogate in DC00 to DFFF. Cut a string between those two escapes and both halves become meaningless, which is why truncating escaped text at a fixed length can corrupt the final character even though the escape itself looks complete.

By default ASCII characters are left readable; tick the option to escape everything, which strict systems and Java .properties files often require. The Unicode Unescape tool reverses it, UTF-8 Encode gives the byte view rather than the code points, and JSON Escape is the better choice when quotes and backslashes need escaping for a JSON string as well.

How to use

  1. Paste the text.
  2. Tick "Escape ASCII too" if the target needs pure ASCII.
  3. Copy the escaped string into your source or config.

Common questions

How are emoji escaped?
As a surrogate pair, two \u sequences, matching how JavaScript and Java store them.
Is the output valid in JSON?
Yes. \uXXXX is valid inside a JSON string.
What is the difference from UTF-8 Encode?
This shows Unicode code points as \u escapes; UTF-8 Encode shows the underlying bytes as \x escapes.