What is text to Unicode conversion?
Unicode gives every character in every writing system a number, called its code point: A is U+0041, é is U+00E9, the euro sign is U+20AC and the pile of poo emoji is U+1F4A9. Converting text to Unicode means writing those characters as their numbers, in one of the notations that programming languages and markup understand, instead of as the characters themselves.
You need this when text has to travel through a place that cannot be trusted with non-ASCII characters: a source file saved in an old encoding, a JSON string, an HTML page, a Java properties file, an email template or a log. é always means é, no matter how the file is saved. It is also the way to find out what an invisible or look-alike character really is, for example when a name pasted from a PDF fails to match.
This page works in two directions. The first card turns text into escapes in five formats; the second turns any mix of escapes back into text. It processes whole code points, not UTF-16 units, so an emoji is one entity and not two broken halves. Everything runs in your browser and nothing is uploaded.
A second mode, Inspect characters, lists every character of a text one by one with its official Unicode name, code point, general category and its bytes in UTF-8 and UTF-16, and marks the invisible ones, so you can tell a zero from a letter O or find a non-breaking space in a pasted password. A third mode, Search by name, finds a character from words of its name or from its code point. The names come from the Unicode Character Database and are loaded from this site only when you open those modes.
How to convert text to Unicode escapes and back
- In the first card, type or paste your text. It opens with
Hello Avengers. - Choose the Format: HTML decimal (
💩), HTML hexadecimal (💩), Escape as used in Python and C (éand\U0001F4A9), JavaScript (\u{1F4A9}) or Code point (U+1F4A9). The format is remembered. - Turn on Keep ASCII as it is to escape only accents, symbols, Chinese, emoji and the like, and leave the plain letters, digits and punctuation readable.
- Copy the result with Copy Unicode.
- To go back, paste escapes in the second card. It opens with
Hi, which readsHi. The text appears below with Copy text. - You do not choose a format for decoding: the reader understands all of them at once, even mixed in the same text.
Code points are written in capital hexadecimal. In the Code point format the escapes are separated by a space, because U+ has no closing mark; a plain space between two escapes is written as U+0020 so it is not lost.
Examples of Unicode conversion
The same text in the five formats
Input Olá 💩:
| Format | Result |
|---|---|
| HTML decimal | Olá 💩 |
| HTML hexadecimal | Olá 💩 |
| Escape (Python, C) | Olá \U0001F4A9 |
| JavaScript | \u{4F}\u{6C}\u{E1}\u{20}\u{1F4A9} |
| Code point | U+004F U+006C U+00E1 U+0020 U+1F4A9 |
Escaping only what is not ASCII
With Keep ASCII as it is, Olá 💩 becomes Olá 💩 in HTML decimal and Ol\u{E1} \u{1F4A9} in JavaScript. ação€ in the Escape format gives ação€.
Decoding mixed escapes
Paste café 😀 é and the result is café 😀 é. The three notations, a four-digit escape, an HTML hexadecimal and an HTML decimal, are read in the same pass.
A surrogate pair back to an emoji
The escape 💩 is how older JavaScript and Java write one emoji as two 16-bit halves. The reader joins them into 💩, and so does \u{1F4A9} or U+1F4A9.
Code points back to text
U+0048 U+0069 becomes Hi: the single space that separates two U+ code points is not part of the text, and the tool removes it.
Common errors and how to fix them
- An escape stays as typed. A value above U+10FFFF, such as
�, is not a Unicode character, so the tool leaves it as written instead of failing the whole text. \u00Edoes not decode. The short escape needs exactly four hexadecimal digits, and\Uneeds eight. Pad with zeros:é.U+41does not decode. The code point form needs four to six hexadecimal digits, so writeU+0041.- The result still has
&or%C3%A9. Those are HTML entities and URL escaping, a different layer. Use HTML entities or the URL encoder first. - Some characters look the same but differ. A Cyrillic
аis U+0430 and a Latinais U+0061. Converting the text to code points is the quickest way to see which one you have.
Frequently asked questions
How do I convert text to Unicode?
Paste the text in the first card, choose the format you need and copy. Each character becomes its code point in that notation.
How do I find the Unicode of an emoji?
Paste the emoji into the first card and choose Code point. 😀 is U+1F600. To pick emoji instead of pasting them, use the emoji picker.
What is the difference between Unicode and UTF-8?
Unicode is the list of characters and their numbers. UTF-8 is one way to store those numbers as bytes, using one to four bytes per character. To see the bytes themselves, use text to binary.
Which format should I use in JavaScript, Python or HTML?
Use the JavaScript format for \u{...} strings, Escape for Python and C style, and HTML decimal or hexadecimal for web pages. In HTML, é and é are the same character.
Is Unicode escaping encryption?
No. It only changes the notation, and anyone can reverse it, as the second card does. To transmit bytes safely in text, use Base64.
How to convert Unicode in code
JavaScript
[...'Olá 💩'].map(c => 'U+' + c.codePointAt(0).toString(16).toUpperCase().padStart(4, '0')).join(' ');
// 'U+004F U+006C U+00E1 U+0020 U+1F4A9'
String.fromCodePoint(0x1F4A9); // '💩'
'\u{1F4A9}'.length; // 2 (UTF-16 units), [...'\u{1F4A9}'].length is 1Python
' '.join(f'U+{ord(c):04X}' for c in 'Olá 💩') # U+004F U+006C U+00E1 U+0020 U+1F4A9
chr(0x1F4A9) # '💩'
'💩'.encode('unicode_escape').decode() # '\\U0001f4a9'
''.join(f'&#{ord(c)};' for c in 'Olá 💩') # HTML decimalBash
printf 'é\n' # é (bash 4.2 or later)