How to use the Unicode encoder
- Paste your text into Text.
- Pick an Escape format:
\uXXXXfor JavaScript, JSON and Java;\u{XXXX}for modern JavaScript;\uXXXX/\UXXXXXXXXfor Python and C;U+XXXXfor code point lists;\XXXXfor CSS; or&#xXXXX;and&#NNNN;for HTML. - Tick Escape only non-ASCII characters if plain letters and digits should stay readable.
- Copy the Escaped output into your source file.
What it does and when to use it
Source files, logs and config systems do not always handle accented letters, other scripts or emoji safely. Writing them as escapes keeps the file pure ASCII while the program still sees the real characters. Common reasons are a build tool that mangles UTF-8, a Java properties file, a test that must show exactly which character is in a string, or a CSS content: value with a symbol.
Escaping is an encoding, not encryption. Anyone can read the text back with the Unicode decoder. To inspect one character in detail, with its name, category and UTF-8 bytes, use the Unicode character lookup. For HTML references with a choice between every character and only special ones, the numeric HTML entities tool has more options.
How it works
The tool walks through your text one code point at a time, so an emoji is treated as one character even though it is stored as two UTF-16 units. For each code point it writes:
\uXXXX: four hex digits; above U+FFFF, the two surrogate halves, each as\uXXXX.\u{XXXX}: the code point in hex inside braces, without padding.- Python / C:
\uXXXXup to U+FFFF, otherwise\Ufollowed by eight hex digits. U+XXXX: the code point with at least four digits, separated by spaces.- CSS: a backslash, the hex code point and one space.
- HTML:
&#x…;with hex or&#…;with decimal.
Hex digits are upper case. The work happens in your browser.
Worked examples
Café ✓ 😀 (\uXXXX) → \u0043\u0061\u0066\u00E9\u0020\u2713\u0020\uD83D\uDE00
Café ✓ 😀 (Python / C) → \u0043\u0061\u0066\u00E9\u0020\u2713\u0020\U0001F600
naïve 😀 (CSS, non-ASCII) → na\EF ve \1F600
Hi 😀 (U+XXXX) → U+0048 U+0069 U+0020 U+1F600
Compare the first two: the emoji is a surrogate pair in JavaScript style but a single \U0001F600 in Python. The CSS line shows the escape-only-non-ASCII option and the space that ends each escape.
Limits and tips
- Characters made of several code points, such as flags, skin-tone emoji or a letter plus a combining accent, become several escapes. That is correct.
- Line breaks and tabs are escaped as
\u000Aand\u0009in the\uformats, not as\nor\t. - For a plain list of numeric codes in decimal or binary, the text to ASCII codes tool is simpler.
Frequently asked questions
Why does an emoji turn into two \u escapes?
Why are plain letters escaped too?
Which format should I pick for JSON?
Why is there a space after each CSS escape?
Does escaping protect text from code injection?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.