Text to binary and back, byte by byte, in UTF-8

Binary translator

Translate text to binary code and binary to text. The letter A is 01000001; the word hi is01101000 01101001. Accents, symbols and emoji go in and come back whole, because the translator speaks the same encoding as your browser.

How to use it

  1. Type in the left box. Each character becomes one or more groups of eight digits on the right, separated by a space, one group per byte.

  2. Paste groups of eight ones and zeros into the right box to read the text. Groups that are not exactly eight binary digits are ignored, never turned into a wrong character.

  3. Accents, symbols and emoji go in as they are, because the translator uses UTF-8, the encoding the whole web uses. An accented letter takes two groups and most emoji four.

What the binary holds

A computer does not store letters; it stores numbers, and an agreement says which number is which letter. The oldest agreement still in use is the ASCII table, with 128 codes, and the most used today is Unicode, which numbers more than a hundred thousand characters from every script. The binary code of a text is the sequence of those numbers written in base two, grouped into bytes of eight digits.

Since Unicode has far more characters than fit in one byte, it needs a rule for spreading a large number over several bytes. That rule is UTF-8, and it was designed so that the 128 ASCII characters keep taking a single byte, identical to the old one. That is why 01101000 01101001 has two groups for two letters, while café has five groups for four letters: 01100011 01100001 01100110 11000011 10101001. The accent costs one extra byte, and the translator returns café with nothing lost.

This translator works on bytes rather than on letters, which is what makes the return trip exact for any text: the bytes that went out are the bytes that come back. It also ignores groups that are not eight digits of one or zero, instead of trying to read rubbish as text.

Binary, hexadecimal and the same byte

Eight binary digits are hard to read, so programmers write the same byte in hexadecimal, with two digits from 0 to F. The conversion is direct, four bits per digit: the letter A is 01000001 in binary and 41 in hex; hi is 68 69. The ASCII tableon the site shows both spellings of each code beside the decimal.

Note that the binary of a character is not the binary of the number it represents. The character zero is00110000, because it is code 48 in the table, and not eight zeros. Anyone using the translator to check base-two arithmetic will be puzzled; what it translates is text.

Table

Letters and digits with their UTF-8 bytes, generated by the same function the translator uses. The first three capitals show the pattern: the same prefix and a counter at the end.

  • A 01000001
  • B 01000010
  • C 01000011
62 entries, generated by the code
CharacterByte
Capitals
A01000001
B01000010
C01000011
D01000100
E01000101
F01000110
G01000111
H01001000
I01001001
J01001010
K01001011
L01001100
M01001101
N01001110
O01001111
P01010000
Q01010001
R01010010
S01010011
T01010100
U01010101
V01010110
W01010111
X01011000
Y01011001
Z01011010
Lowercase
a01100001
b01100010
c01100011
d01100100
e01100101
f01100110
g01100111
h01101000
i01101001
j01101010
k01101011
l01101100
m01101101
n01101110
o01101111
p01110000
q01110001
r01110010
s01110011
t01110100
u01110101
v01110110
w01110111
x01111000
y01111001
z01111010
Digits
000110000
100110001
200110010
300110011
400110100
500110101
600110110
700110111
800111000
900111001

Frequently asked

How is a letter written in binary?

Every character has a number in the character table, and that number is written in base two with eight digits. Capital A is 65, which in binary is 01000001. Lowercase a is 32 higher, 01100001: the difference between upper and lower case is a single bit.

Why eight digits?

Because computer memory is organised in bytes of eight bits, and a byte holds the numbers from 0 to 255. The 128 characters of the ASCII table fit in seven bits, and the eighth was spare; UTF-8 uses that bit to mark the characters that need more than one byte.

How do accents and emoji become binary?

In UTF-8, a character outside the ASCII table takes two to four bytes, each written with eight digits. An e with an acute accent is two bytes: 11000011 10101001. A smiling-face emoji is 4 bytes. The translator returns the original text exactly, because nothing is discarded on the way.

Are binary and hexadecimal the same thing?

They represent the same byte in different bases. Every four binary digits correspond to one hexadecimal digit, so a byte is eight binary digits or two hexadecimal ones: the letter A is 01000001 in binary and 41 in hex. The ASCII table on the site shows both side by side.

Is the zero in binary zero?

The character zero, the one in a text, is not the number zero. It is code 48, 00110000. It is a common confusion on first reading binary: what is encoded is the symbol, not the value.