What Is Binary Code?
Binary code is a way of writing information with only two symbols, 0 and 1. Computers store every number, letter, image and sound as long rows of these two digits.
Updated
Binary code in one minute
Binary code uses two digits, 0 and 1, to represent data. Each digit is called a bit, short for binary digit. On its own, one bit can say only yes or no, on or off. Put bits in a row and they can stand for anything: a number, a letter, the color of a pixel, or one instruction for a processor.
What a row of bits means depends on the agreement used to read it. The same eight bits, 01000001, are the number 65 when read as a number and the capital letter A when read as text. The bits never change; the rule for reading them does.
You can try it below. Type a word to see its binary, or paste binary to read it back. For longer messages, use the binary translator, which detects the direction for you.
Try it: text and binary
Type text to see its binary, or type 0s and 1s to read them as text.
Text → binary
Bits and bytes
A single bit has two possible values. Two bits have four combinations (00, 01, 10, 11), and every extra bit doubles the count. Eight bits make a byte, and a byte has 256 possible values, from 00000000 to 11111111, which is 0 to 255.
Eight bits became the usual size of a byte, and 256 values are enough to cover every letter, digit and symbol on an English keyboard, with room to spare. File sizes are counted in bytes: a kilobyte is about a thousand of them, a megabyte about a million.
Seven bits hold 128 values. ASCII, the character set behind English text, is a 7-bit code, so it has exactly 128 characters. That is why you still see 7-bit binary in some puzzles and textbooks.
Numbers in binary
Binary is a base-2 number system. Each position is worth twice the one to its right: 1, 2, 4, 8, 16, 32 and so on. To read a binary number, add the place values of the positions that hold a 1. Here is 101101 worked out.
| Bit | Place value | Value |
|---|---|---|
| 1 | 2⁵ = 32 | 32 |
| 0 | 2⁴ = 16 | 0 |
| 1 | 2³ = 8 | 8 |
| 1 | 2² = 4 | 4 |
| 0 | 2¹ = 2 | 0 |
| 1 | 2⁰ = 1 | 1 |
32 + 8 + 4 + 1 = 45
Counting in binary
Decimal, the system people use every day, has ten digits and each place is worth ten times the one to its right. Binary works the same way with two digits. Counting goes 0, 1, 10, 11, 100, 101, 110, 111, 1000. So 1 + 1 in binary is 10, which is two.
Converting the other way is just as mechanical: divide the number by 2, write down the remainder, and repeat until you reach 0. The remainders read from bottom to top are the binary number. The binary to decimal converter shows every step of adding place values, and the decimal to binary converter shows the second.
Long binary numbers are hard for people to read, so programmers often group them four bits at a time and write each group as one hexadecimal digit. 11111111 becomes FF. The binary to hex converter does this grouping for you.
Text in binary: ASCII and UTF-8
Computers store text by giving every character a number and storing the number in binary. The agreement that matches characters to numbers is called a character encoding.
ASCII, first published in 1963 and revised in 1967, assigns the numbers 0 to 127 to English letters, digits, punctuation and a set of control codes. Capital A is 65, lowercase a is 97, and the digit 0 is 48. In 8-bit binary, A is 01000001 and a is 01100001. The two differ by one bit, which is true for every letter pair. The full list is in the ASCII table.
UTF-8 is the encoding used by almost every web page today. For the 128 ASCII characters it uses the exact same single bytes, so English text looks identical in both. For other characters it uses two to four bytes. The letter é, for example, is two bytes: 11000011 10101001. Most emoji take four.
This is why a binary to text converter needs to know the encoding. Read as UTF-8, those two bytes are one letter; read as ASCII, they are two invalid values.
Why computers use binary
Computer hardware is built from billions of tiny switches called transistors. A switch that only has to be on or off is easy to build, fast to flip and hard to misread. A small amount of electrical noise can blur the difference between ten voltage levels, but it rarely turns a clear "on" into "off".
Two states also map neatly onto logic. True and false, yes and no, 1 and 0 can be combined with simple rules (AND, OR, NOT) to build circuits that add numbers, compare values and store data. Every calculation a processor makes comes down to these rules applied very fast.
Storage works the same way. A hard drive records bits as tiny magnetic regions pointing one of two ways, an optical disc as pits and flat areas, and flash memory as cells that hold or lack an electric charge.
- Reliable: two states are easy to tell apart, even with noise.
- Simple: a switch with two positions is easy to make in huge numbers.
- Logical: binary values work directly with true and false logic.
A short history of binary
Two-symbol systems are old. The I Ching, a Chinese text more than two thousand years old, arranges broken and unbroken lines in patterns that can be read as binary numbers. Several cultures also used doubling methods for arithmetic.
The modern binary number system was described by the German mathematician Gottfried Wilhelm Leibniz. His 1703 paper on binary arithmetic showed how to count and calculate using only 0 and 1.
In 1854 the English mathematician George Boole published a system of logic built on two values, true and false, now called Boolean algebra. In 1937 Claude Shannon showed in his master's thesis that electrical switching circuits could carry out Boolean logic. That link between binary logic and circuits is the basis of digital computers.
By the 1940s, electronic binary computers were running calculations, and later encodings like ASCII let them handle text. Today the same principle runs phones, servers and the page you are reading.
Where to go next
To decode binary by hand, follow the three steps in how to read binary, which ends with practice questions. To look up a single letter, use the binary alphabet chart.
Frequently asked questions
Why do computers use binary?
Their circuits are made of switches that are either on or off. Two states are cheap to build, fast to switch and hard to confuse, and they map directly onto true and false logic.
Is 1 on or off in binary?
By convention, 1 means on (or true, or a high voltage) and 0 means off. The digits themselves are just symbols; the hardware decides what physical state stands for each.
What is 1 + 1 in binary?
`10`, which is two in decimal. Like 9 + 1 in decimal, the sum runs out of digits in the ones place, so it carries 1 into the next place.
Who invented binary code?
No single person. Gottfried Wilhelm Leibniz described the modern binary number system in 1703, building on much older two-symbol ideas. George Boole added two-valued logic in 1854, and Claude Shannon connected that logic to electrical circuits in 1937.