bitlvl
EN

Text ⇄ binary / hex / ASCII

Type text and see its bytes, or paste binary, hex or decimal bytes and read them as text. The table underneath shows each character, its code point and how UTF-8 stores it.

Text is numbers

A computer stores text as numbers. Each character has a code point (the letter A is 65, a is 97, 0 is 48), and an encoding decides how that number becomes bytes. ASCII covers 128 characters in one byte each; Unicode covers more than a million, and UTF-8 is the encoding that writes them as one to four bytes while keeping ASCII unchanged.

So Hi is 72 and 105, which in binary are 01001000 and 01101001, and in hex 48 69. The accented é is code point 233 but is stored as two bytes, C3 A9; the check mark ✓ is three bytes, E2 9C 93; an emoji is four.

How UTF-8 packs a code point

Code point rangeBytesBit layout
U+0000 – U+007F10xxxxxxx
U+0080 – U+07FF2110xxxxx 10xxxxxx
U+0800 – U+FFFF31110xxxx 10xxxxxx 10xxxxxx
U+10000 – U+10FFFF411110xxx 10xxxxxx 10xxxxxx 10xxxxxx

The leading bits of the first byte say how long the sequence is, and every continuation byte starts with 10. That design lets a decoder resynchronise after an error and is why you can search UTF-8 text byte by byte.

ASCII reference

Printable ASCII runs from 32 (space) to 126 (~). Digits are 48–57, upper-case letters 65–90, lower-case 97–122. The difference between upper and lower case is exactly bit 5 (value 32), which is why c | 0x20 lower-cases an ASCII letter. Codes 0–31 are control characters: 9 is tab, 10 is line feed, 13 is carriage return, 27 is escape.

Questions

How do I convert text to binary by hand?

Look up each character's ASCII code (A = 65), then convert that decimal number to binary and pad it to 8 bits: 65 = 01000001. Non-ASCII characters first need to be turned into UTF-8 bytes.

Why does one character become more than one byte?

Because UTF-8 uses 2, 3 or 4 bytes for anything outside ASCII. é is C3 A9, 日 is E6 97 A5, 😀 is F0 9F 98 80. The table under the tool shows this per character.

What is the binary for the letter A?

01000001 (decimal 65, hex 41). Lower-case a is 01100001 (97, hex 61): the same with bit 5 set.

Why does binary-to-text give an error?

Each group must be a byte (8 binary digits, or a value 0–255), and the bytes must form valid UTF-8. A lone byte above 127, or a continuation byte without a lead byte, is not valid text.

Is this the same as Base64?

No. This shows the actual bytes of the text in a readable base. Base64 is a different, denser scheme for carrying arbitrary bytes as text. See the Base64 tool.