What is text to binary conversion?
Computers store text as numbers, and numbers as bits. Converting text to binary means writing, for every character, the bits that represent it. The letter H is the number 72, which is 01001000 in binary: eight bits, one byte. "Hello" is five bytes, so five groups of eight zeros and ones.
The exact bits depend on the encoding. This tool uses UTF-8, the encoding of the web and of most files today. Plain English letters, digits and punctuation, the ASCII range, take one byte each. Accented letters take two bytes, characters such as the euro sign take three, and emoji take four. So é is not one group but two: 11000011 10101001.
People convert text to binary to learn how encodings work, to solve a puzzle or a school exercise, to hide a message in a "geek" greeting card, or to inspect the bytes behind a string while debugging. This page does it in both directions: text to binary, and binary back to text. It runs in your browser and nothing is uploaded.
How to convert text to binary and back
- In the first card, type or paste your text. It opens with
Hello world, so the binary is already shown. - Choose what goes Between bytes: a space (the default, easiest to read), nothing (one long string) or a line break (one byte per line).
- Choose the Bits per character: 8 bits (one byte) or 7 bits for pure ASCII. If your text has any character outside ASCII, 7 bits is not enough and the tool switches to 8-bit UTF-8 bytes, with a note that says so.
- Press Copy binary to copy the result.
- To go back, paste the zeros and ones in the second card. The text appears below and can be copied with Copy text.
- Anything that is not a
0or a1is ignored when reading binary, so spaces, line breaks and commas between the bytes do not matter, as long as the bits themselves are complete.
The reader groups the bits in eights. If the number of bits is not a multiple of 8 but is a multiple of 7, it reads them as 7-bit ASCII. Otherwise it reports that the binary is invalid.
Examples of text to binary
Hello world
Hello world in 8 bits, separated by spaces:
01001000 01100101 01101100 01101100 01101111 00100000 01110111 01101111 01110010 01101100 01100100The space between the words is also a byte: 00100000.
Seven bits and no separator
Hi in 7-bit ASCII is 1001000 1101001. In 8 bits and with no separator between bytes it is 0100100001101001.
Accents, the euro and emoji
| Character | UTF-8 bytes in binary |
|---|---|
A | 01000001 |
é | 11000011 10101001 |
€ | 11100010 10000010 10101100 |
😀 | 11110000 10011111 10011000 10000000 |
Binary to text
01001000 01101001 becomes Hi, and 11000011 10101001 becomes é. The long form 0100100001101001 also works, because the tool cuts it into groups of eight.
One byte per line
With Line break between bytes, Oi gives:
01001111
01101001Common errors and how to fix them
- Binary must be groups of 8 bits (0 and 1), or of 7 bits for ASCII, forming valid UTF-8 text. Check that no byte is missing or cut. The count of bits is not a multiple of 8 or 7. For example
01000001 0100has 12 bits. Copy the binary again and make sure the last byte is complete. - The same message appears for a valid length. Eight bits can still be invalid UTF-8:
11111111is not a valid byte sequence in UTF-8. Check for a flipped bit or a missing byte. - My text with
çorãshows 16 bits for one letter. That is correct. UTF-8 writes non-ASCII characters with two to four bytes. Choose 8 bits; 7 bits only works for plain ASCII. - I pasted binary from a different encoding. Older systems used Latin-1 or UTF-16, where
éis one byte or two different bytes. The tool reads UTF-8 only, so the result may be an error or odd characters. - A
0bprefix breaks the result. The0of0bis read as a bit, so remove the prefix before pasting.
Frequently asked questions
How do I convert text to binary?
Type the text in the first card and copy the result. By hand, look up each character's code, then write it in base 2 with 8 digits; the base converter does the base change for a single number.
How do I convert binary to text?
Paste the bits in the second card. Each group of 8 bits is a byte, and the bytes are decoded as UTF-8. 01001000 01101001 is Hi.
Is binary the same as ASCII?
No. ASCII is a table of 128 characters with a number each, and binary is a way of writing numbers. ASCII text in binary uses 7 bits per character, usually padded to 8. To see the numbers of every character, including emoji, use text to Unicode.
Why does an emoji take 32 bits?
In UTF-8, characters above the first 65,536 positions of Unicode, including most emoji, take four bytes, and four times 8 is 32 bits.
Is binary a form of encryption?
No. Anyone can convert it back in a second, as this page shows. To protect or fingerprint data use a hash, and to send bytes in text form, Base64.
How to convert text to binary in code
JavaScript
const bytes = new TextEncoder().encode('Olá');
const binary = Array.from(bytes, b => b.toString(2).padStart(8, '0')).join(' ');
// '01001111 01101100 11000011 10100001'
const text = new TextDecoder().decode(Uint8Array.from('11000011 10101001'.split(' '), b => parseInt(b, 2))); // 'é'Python
binary = ' '.join(f'{b:08b}' for b in 'Hello'.encode('utf-8'))
# '01001000 01100101 01101100 01101100 01101111'
text = bytes(int(x, 2) for x in '11000011 10101001'.split()).decode('utf-8') # 'é'Go
for _, b := range []byte("Olá") {
fmt.Printf("%08b ", b) // 01001111 01101100 11000011 10100001
}Bash
printf 'Hi' | xxd -b -c1 | cut -d' ' -f2 | paste -sd' ' - # 01001000 01101001
echo '01001000 01101001' | perl -lape '$_ = pack("(B8)*", @F)' # Hi