How Does Binary Code Work? Text to Binary Explained
Quick answer: How does binary code work? It writes everything with just two digits, 0 and 1. Each digit is a bit, eight bits make a byte, and one byte can hold any number from 0 to 255. Text becomes binary because a character set such as ASCII or UTF-8 gives every character a number, so the word “Hi” is 01001000 01101001.
That answer hides a few steps, and each one is simple on its own. Seeing how binary code works is easier with a live example, so this post walks through bits, place values and character sets, then converts a real word by hand. You can check any example against the text to binary converter as you read.
How does binary code work? Bits, bytes and place values
A bit is a single 0 or 1. A byte is, in almost all modern use, a group of eight bits. Wikipedia’s article on the byte calls eight bits a “de facto standard” and notes that the size has historically varied from 1 to 48 bits.
Binary is a place-value system, like the decimal numbers you use every day. The difference is that each place is worth twice the place to its right, not ten times. In decimal, 305 means 3 hundreds, 0 tens and 5 ones. In an eight-bit byte the places are worth 128, 64, 32, 16, 8, 4, 2 and 1. A 1 switches a place on, so you count its value. A 0 leaves it off.
| Place value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| Bits for 72 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 |
Only the 64 and 8 places are on, and 64 + 8 = 72. Eight places give 2 to the eighth power, or 256 different patterns, which is the numbers 0 through 255.
A byte holds only a number. What the number means depends on an agreement between the sender and the reader. For text, that agreement is a character set.
Worked example: “Hi” in binary
ASCII, a character set first published in 1963, gives capital H the number 72 and lowercase i the number 105. Turn each number into eight bits:
- H is 72, which is 64 + 8, so the byte is 01001000.
- i is 105, which is 64 + 32 + 8 + 1, so the byte is 01101001.
Put the two bytes side by side and “Hi” is 01001000 01101001. That is two characters, two bytes and 16 bits. Paste “Hi” into the converter and it gives you the same thing. The page can also show the working for the first character, and it has a table that breaks longer text down character by character.
Longer text follows the same rule: one byte per character, in order. Add an exclamation mark, which is 33 and so 00100001, and “Hi!” becomes 01001000 01101001 00100001. A space is a character too. It is 32, or 00100000. So how does binary code work for a whole sentence? The same way, one byte at a time.

ASCII and UTF-8: how characters get their numbers
According to Wikipedia’s ASCII article, ASCII has 128 code points, numbered 0 to 127, which fit in seven bits. Of those, 95 are printable and 33 are control codes. Capital A is 65, lowercase a is 97, the digits 0 to 9 are 48 to 57, and the space is 32.
ASCII covers basic English text and little else. UTF-8, defined in RFC 3629, covers every Unicode character by using one to four bytes per character. Its key design choice is that ASCII characters are written as a single byte with the same value they have in ASCII. So plain English text comes out the same in both, and the first bit of each of those bytes is always 0. Everything else takes more bytes, following these patterns:
| Code point range | Bytes | Byte pattern |
|---|---|---|
| U+0000 to U+007F | 1 | 0xxxxxxx |
| U+0080 to U+07FF | 2 | 110xxxxx 10xxxxxx |
| U+0800 to U+FFFF | 3 | 1110xxxx 10xxxxxx 10xxxxxx |
| U+10000 to U+10FFFF | 4 | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx |
Uppercase and lowercase letters differ by one bit
Compare A and a. Capital A is 01000001 (65) and lowercase a is 01100001 (97). Only one bit changed, the third from the left, which is worth 32. The same is true for every letter pair from A to Z, so a lowercase letter is always its capital plus 32. Wikipedia describes this as the lowercase letters differing from the uppercase ones by a single bit.
You can see it in our example. “Hi” is 01001000 01101001, while “HI” is 01001000 01001001. The H byte is identical, and the second byte differs only in that one bit.
If you only need text switched between cases, the uppercase converter and lowercase converter handle that without any bit counting.
Why eight bits?
ASCII itself is a seven-bit code. Its committee chose seven bits to keep data transmission costs down. But computers came to be built around eight-bit bytes, so it became common to store each character in a full byte, which left one spare bit. The byte article says the prominence of the IBM System/360 led to the ubiquitous adoption of the eight-bit size, and that eight bits is a convenient power of two permitting the values 0 through 255.
The spare bit is also why 8-bit extensions of ASCII appeared. They kept the original 128 characters and added more after them, though “extended ASCII” has no official status. UTF-8 builds on the same eight-bit unit. In the converter, UTF-8 (8-bit) is the default, with ASCII (7-bit) and UTF-16 (16-bit) as other choices.
How emoji and accented letters work in UTF-8
Take the grinning face emoji, code point U+1F600. It falls in the four-byte range, so UTF-8 writes it as four bytes: 11110000 10011111 10011000 10000000. The first byte starts with 11110, which says “this character takes four bytes”, and each byte after it starts with 10, which marks a continuation. Remove those marker bits and the remaining 21 bits are the code point.
An accented letter is smaller. The letter é is U+00E9 and takes two bytes: 11000011 10101001. The euro sign (€) is U+20AC and takes three: 11100010 10000010 10101100. In 7-bit ASCII mode the converter cannot represent any of these, so it writes a question mark instead.
Convert text to binary in your browser
Type or paste text into the text to binary converter and it writes the binary as you go. It separates bytes with a space, a new line or nothing, and lets you copy the result or download it as a .txt file. It also converts binary back into text, and the binary to text converter is the page built for decoding. Everything runs in your browser.
Frequently asked questions
What is the binary code for A?
Capital A is 01000001, which is 65. Lowercase a is 01100001, which is 97. These are the same in ASCII and UTF-8.
How many bits are in a byte?
Eight, in almost all modern use. The size of a byte has varied historically, so the unambiguous term for exactly eight bits is an octet.
What is the difference between ASCII and UTF-8?
ASCII has 128 characters in seven bits. UTF-8 covers every Unicode character with one to four bytes, and it writes ASCII characters as the same single byte.
Is the number 5 the same as the character 5 in binary?
No. The number 5 stored in a byte is 00000101. The text character “5” is ASCII 53, which is 00110101.