Unicode Converter: Code Points, UTF-8, UTF-16, Escapes
Convert text to and from Unicode code points, binary, octal, decimal or hex numbers, UTF-8, UTF-16 and UTF-32 code units, byte arrays and JavaScript, JSON, Python, C, Java, CSS or HTML escapes, with a per-character breakdown. Nothing is uploaded.
0 characters, 0 bytes
0 characters, 0 bytes
About the Unicode converter
This page converts text to its Unicode representation and back. Every character in Unicode has a number, its code point, written as U+ followed by at least four hexadecimal digits: H is U+0048 and the grinning face emoji is U+1F600. Computers then store that number as code units in an encoding form, UTF-8, UTF-16 or UTF-32, and programmers write it into source code as an escape sequence. The converter shows any of these views for the text you type, and reads any of them back into text. Everything runs in your browser; nothing is uploaded and your text never leaves your device.
How to use it
Steps
- Choose Text to Unicode to encode, or Unicode to text to decode.
- Pick a Representation: code points, code-point numbers, UTF-8, UTF-16 or UTF-32 code units, a UTF-8 byte array, or a string literal.
- Set the options that appear for that representation, such as the number base, the UTF-16 byte order, the escape style or the separator.
- Type or paste into Input. The result appears at once; press Copy, or Swap to turn the output back into the input and reverse the direction.
The representations
Code points
The standard U+XXXX notation, padded to four hex digits and longer for characters beyond the Basic Multilingual Plane. When decoding, the page also accepts U+48, 0x48, \u{1F600}, H and bare hex, separated by spaces, commas or new lines.
Code-point numbers
The same numbers in binary, octal, decimal or hex, one number per character. H is 1001000 in binary, 110 in octal, 72 in decimal and 48 in hex. For the first 128 characters the decimal number is the familiar ASCII code.
UTF-8, UTF-16 and UTF-32
UTF-8 writes each code point as one to four bytes, UTF-16 as one or two 16-bit code units, and UTF-32 as a single 32-bit unit. Characters above U+FFFF need a surrogate pair in UTF-16: the emoji U+1F600 becomes D83D DE00. The byte order option swaps the two bytes of each UTF-16 unit, so little-endian output reads 3DD8 00DE. Decoding accepts groups separated by spaces or commas, or an unbroken run of hex digits.
Byte array
The UTF-8 bytes as a decimal array such as [72, 195, 169], ready to paste into code that builds a buffer. Decoding accepts decimal or 0x hex values from 0 to 255.
String literals
Escape sequences for JavaScript, JSON, Python, C and C++, Java, CSS and HTML. JSON and Java write characters beyond U+FFFF as two UTF-16 escapes, while JavaScript can use the \u{...} form and Python and C use an eight-digit \U escape. Turn on Escape non-ASCII only to keep plain ASCII readable and escape only accented letters, symbols and emoji.
Character breakdown
For short texts of up to 64 characters, a table under the converter lists every character with its code point, its UTF-8 bytes and its UTF-16 code units. Characters in the ASCII and Latin-1 ranges also show their official Unicode name, such as LATIN SMALL LETTER E WITH ACUTE. Invisible control characters are shown with their Control Pictures symbol so a stray tab or line feed is easy to spot.
Errors are reported, not hidden
A Unicode scalar value runs from U+0000 to U+10FFFF and excludes the surrogate range U+D800 to U+DFFF. When a decoded value falls outside that range, or a UTF-16 surrogate has no partner, the page names each invalid value and its position instead of inserting a replacement character. Groups that are not numbers, and bytes that do not form valid UTF-8, are reported by their group number. Inputs are limited to 1,000,000 characters so the page stays responsive.
Related tools
To see the UTF-8 bytes of text as binary, decimal or hex codes, use Text to Binary. The HTML Encoder and Decoder handles named HTML entities, the URL Encoder and Decoder handles percent-encoding, and Base64 packs bytes into printable text. To convert a single number between bases, try the Number Base Converter.
Open-source credits
The conversion logic is implemented in-house in TypeScript, with no third-party library. It follows the encoding forms defined in The Unicode Standard, chapter 3 (sections 3.9 and 3.10), and is tested against the standard's own encoding-form example U+004D U+0430 U+4E8C U+10302. UTF-8 bytes come from the browser's TextEncoder and TextDecoder, as specified in RFC 3629 and the WHATWG Encoding Standard. The character names come from the Unicode Character Database file UnicodeData.txt, and the escape formats follow ECMA-262 for JavaScript, RFC 8259 for JSON, and the CSS Syntax Module for CSS.
Frequently asked questions
What is the difference between a code point and a code unit?
A code point is the number Unicode assigns to a character, such as U+1F600 for the grinning face. A code unit is the fixed-size piece an encoding form stores: one byte in UTF-8, 16 bits in UTF-16 and 32 bits in UTF-32. One code point can need several code units, for example four UTF-8 bytes or two UTF-16 units for that emoji.
Why does an emoji turn into two \u escapes in JSON and Java?
JSON and Java only have four-digit \u escapes, which reach U+FFFF. Characters above that are stored in UTF-16 as a surrogate pair, a high surrogate from D800 to DBFF followed by a low surrogate from DC00 to DFFF, so each half gets its own escape. Decoding joins the pair back into one character.
What does the UTF-16 byte order option change?
Each UTF-16 code unit is two bytes. Big-endian writes the high byte first, which matches the usual way the hex value is read, while little-endian writes the low byte first, as Windows and most x86 software store it in memory and in files. The option swaps the two bytes of every unit when encoding and swaps them back when decoding.
Why is a code point such as U+D800 or U+110000 rejected?
Unicode ends at U+10FFFF, so larger numbers are not characters at all. The range U+D800 to U+DFFF is reserved for UTF-16 surrogates and never stands for a character on its own. The converter lists each such value with its position instead of silently replacing it, so you can find the broken data.
Which characters does Escape non-ASCII only leave alone?
It keeps the printable ASCII characters from space to tilde exactly as typed and escapes everything else, including control characters such as tabs and line feeds. The style's own escape character, the backslash or the ampersand for HTML, is escaped too, so the result always decodes back to the original text.
Why are character names shown only for some characters?
The page carries a small built-in table of the official names for the first 256 code points, the ASCII and Latin-1 ranges, so it stays fast and works offline. The full Unicode name list has well over a hundred thousand entries, so other characters show their code point and encodings without a name.