By · Updated

Unicode Converter

Text to Code Points, HTML Entities, JS and Python Escapes and UTF-8 Bytes

No ratings yet

OneTask is free, with no sign-up, and built by one person.
If this tool saved you time, a coffee helps keep new ones coming.

How the Unicode Converter works

This Unicode converter turns text into code points, HTML entities, escape sequences or raw UTF-8 and UTF-16 bytes, and turns any of them back into text. Emoji and other characters outside the Basic Multilingual Plane are handled correctly, and nothing leaves your browser.

Every character in Unicode has a number, its code point, written as U+ followed by at least four hex digits: A is U+0041, é is U+00E9 and 😀 is U+1F600. Code points are abstract. To store or send text, they must be written down in an encoding or an escape format, and each language, file format and protocol has its own. Most mojibake and "invalid character" errors come from mixing two of them.

What the Unicode converter outputs

Encoding takes each character and writes it in the chosen format:

Format é 😀
Code points U+00E9 U+1F600
Decimal 233 128512
HTML decimal é 😀
HTML hex é 😀
JavaScript and JSON \u00E9 \uD83D\uDE00
CSS \E9 \1F600
Python \u00E9 \U0001F600
UTF-8 bytes C3 A9 F0 9F 98 80
UTF-16 units 00E9 D83D DE00

Non-ASCII only leaves plain letters, digits and punctuation as they are and converts everything else. That is what you usually want when making a string safe for an ASCII-only file. All characters converts every character, which helps when you are inspecting text.

Surrogate pairs and why emoji look different

JavaScript, JSON, Java and C# store strings as UTF-16, where each unit is 16 bits. Code points above U+FFFF do not fit, so they are split into a pair of units called a surrogate pair: a high surrogate from D800 to DBFF followed by a low surrogate from DC00 to DFFF. That is why 😀 becomes \uD83D\uDE00 in JSON and why "😀".length is 2 in JavaScript. The UTF-16 units reading shows this count, while Code points counts what a person would call characters. Python and CSS escapes can name the code point directly, so they need no pair.

UTF-8 bytes

UTF-8 is the encoding of almost all web pages and files today. It uses one byte for ASCII, two for most Latin, Greek, Cyrillic, Hebrew and Arabic letters, three for the rest of the Basic Multilingual Plane including Chinese, Japanese and Korean, and four for emoji and historic scripts. The UTF-8 bytes reading gives the stored size, which matters for database column limits, SMS segments and HTTP header caps that count bytes rather than characters.

When decoding bytes, the tool accepts spaces, commas, 0x, \x or % between pairs, so you can paste from a hex dump, a C string or a URL. Invalid sequences are rejected rather than silently replaced, so a missing or extra byte is easy to spot.

Decoding tips

Pick the format that matches what you pasted. HTML decoding also understands named entities such as é and  , and accepts decimal and hex forms together. The JavaScript option also reads \u{1F600} and \x41 escapes. Text around the escapes is kept, so you can paste a whole source line.

If the output looks like é instead of é, the text was UTF-8 read as Latin-1 or Windows-1252 somewhere upstream. Encode the garbled text to UTF-8 bytes and compare with what you expected to see where the extra byte crept in.

Where each format is used

Normalisation

Some characters can be written two ways. é can be a single code point or e followed by a combining acute accent, U+0301. They look identical but convert differently and compare as unequal in most code. If two strings that look the same will not match, encode both with All characters to see whether one holds a combining mark.

FAQ

Why does an emoji produce two JavaScript escapes?

JavaScript and JSON strings use UTF-16, and emoji have code points above U+FFFF, which need two 16-bit units called a surrogate pair. Both escapes together make one character, and splitting them produces an invalid string.

How many bytes does my text take in UTF-8?

The UTF-8 bytes reading shows it for whatever is in the box. ASCII characters take one byte, most accented and non-Latin letters two or three, and emoji four, so the byte count is often higher than the character count.

Can I decode named HTML entities?

Yes. Choose either HTML format and Decode. Named entities such as ©,   and é are decoded alongside numeric ones, and any text around them is left unchanged.

Is my text sent anywhere?

No. Encoding and decoding happen in your browser with JavaScript. Nothing you paste is uploaded or stored, so the converter is safe for private strings and source code.

See also: all Data & Code tools, Units, Images, Audio & Video, Documents.

Related tools