Binary Translator
What is Binary?
Binary is a base-2 number system that uses only two digits: 0 and 1. Every piece of data a computer processes β text, images, audio, programs β is ultimately stored as a sequence of these two values. A single binary digit is called a bit; eight bits form a byte, which can represent 256 different values (28 = 256). The letter "A" in ASCII is the byte 01000001, which is the number 65 in decimal.
Binary exists because digital circuits are built from transistors that have two states: on and off. The entire stack β from logic gates to processors to programming languages β rests on this foundation. Understanding binary is not just academic; it appears in debugging, networking, file formats, and permissions.
How Text-to-Binary Translation Works
Converting text to binary is a two-step process. First, each character is mapped to a number using a character encoding β ASCII for English letters and symbols, UTF-8 for everything else including emoji and accented characters. Second, each number is converted to its binary representation, padded to 8 bits per byte.
For ASCII characters (codes 0-127), each character is exactly one byte. The letter "H" is 72 in decimal, which is 01001000 in binary. The word "Hi" becomes 01001000 01101001 β two bytes, 16 bits.
For characters outside ASCII β accented letters, CJK characters, emoji β UTF-8 uses multiple bytes per character. The emoji π is four bytes in UTF-8: 11110000 10011111 10011010 10000000. This tool handles UTF-8 automatically, so emoji and international text convert correctly. This is the same UTF-8 encoding step that matters in Base64 encoding and hashing β get the encoding wrong and the output is wrong.
ASCII Table β Printable Characters
| Dec | Binary | Char | Dec | Binary | Char | Dec | Binary | Char |
|---|---|---|---|---|---|---|---|---|
| 32 | 00100000 | (space) | 64 | 01000000 | @ | 96 | 01100000 | ` |
| 33 | 00100001 | ! | 65 | 01000001 | A | 97 | 01100001 | a |
| 34 | 00100010 | " | 66 | 01000010 | B | 98 | 01100010 | b |
| 35 | 00100011 | # | 67 | 01000011 | C | 99 | 01100011 | c |
| 36 | 00100100 | $ | 68 | 01000100 | D | 100 | 01100100 | d |
| 37 | 00100101 | % | 69 | 01000101 | E | 101 | 01100101 | e |
| 38 | 00100110 | & | 70 | 01000110 | F | 102 | 01100110 | f |
| 48 | 00110000 | 0 | 71 | 01000111 | G | 103 | 01100111 | g |
| 49 | 00110001 | 1 | 72 | 01001000 | H | 104 | 01101000 | h |
| 50 | 00110010 | 2 | 73 | 01001001 | I | 105 | 01101001 | i |
| 51 | 00110011 | 3 | 74 | 01001010 | J | 106 | 01101010 | j |
| 52 | 00110100 | 4 | 75 | 01001011 | K | 107 | 01101011 | k |
| 53 | 00110101 | 5 | 76 | 01001100 | L | 108 | 01101100 | l |
| 54 | 00110110 | 6 | 77 | 01001101 | M | 109 | 01101101 | m |
| 55 | 00110111 | 7 | 78 | 01001110 | N | 110 | 01101110 | n |
| 56 | 00111000 | 8 | 79 | 01001111 | O | 111 | 01101111 | o |
| 57 | 00111001 | 9 | 80 | 01010000 | P | 112 | 01110000 | p |
Binary in Programming
Binary is not just a theoretical concept β it shows up directly in everyday programming:
- Unix file permissions.
chmod 755is three octal digits, each representing three permission bits: read (4), write (2), execute (1). The binary is111 101 101β owner can do everything, group and others can read and execute. - Network subnet masks.
255.255.255.0is11111111.11111111.11111111.00000000in binary. The boundary between ones and zeros is the boundary between the network and host portions of an IP address. - Bitwise flags. Feature toggles, permission sets, and status registers pack multiple boolean values into a single integer. Checking
flags & 0x04tests whether bit 2 is set. - Color values. The hex color
#FF5733is three bytes in binary:11111111 01010111 00110011β red 255, green 87, blue 51.
How to Convert in Code
JavaScript
// Text to binary
const binary = [...new TextEncoder().encode("Hello")]
.map(b => b.toString(2).padStart(8, "0")).join(" ");
// Binary to text
const text = new TextDecoder().decode(
new Uint8Array("01001000 01101001".split(" ")
.map(b => parseInt(b, 2)))
);
Python
# Text to binary
binary = ' '.join(format(b, '08b') for b in "Hello".encode('utf-8'))
# Binary to text
text = bytes(int(b, 2) for b in "01001000 01101001".split()).decode('utf-8')
Bash
# Text to binary (one byte per line)
echo -n "Hello" | xxd -b | cut -d' ' -f2-7
# Binary to text
echo "01001000 01101001" | perl -lape '$_=pack"B*",join"",@F'
Encoding Matters: ASCII vs UTF-8
ASCII maps 128 characters to the numbers 0-127, each fitting in a single byte. It covers English letters, digits, punctuation, and control characters. For decades this was sufficient, but it cannot represent accented characters, Chinese, Arabic, or emoji.
UTF-8 is a variable-length encoding that is backward-compatible with ASCII: characters 0-127 are identical. Characters above 127 use 2-4 bytes, with leading bits that indicate the byte count. This is why "Γ©" is two bytes in UTF-8 (11000011 10101001) but one byte in Latin-1 (11101001). This tool uses UTF-8, which is the encoding of the modern web β over 98% of websites use it.
Common Binary Prefixes
| Prefix | Symbol | Bytes | Decimal approx. |
|---|---|---|---|
| Kilobyte | KB | 1,024 | ~1 thousand |
| Megabyte | MB | 1,048,576 | ~1 million |
| Gigabyte | GB | 1,073,741,824 | ~1 billion |
| Terabyte | TB | 1,099,511,627,776 | ~1 trillion |
The discrepancy between binary (1 KB = 1,024 bytes) and decimal (1 kB = 1,000 bytes) definitions is why a "500 GB" hard drive shows as 465 GB in your operating system. Storage manufacturers use decimal; operating systems use binary. The IEC introduced unambiguous prefixes β kibibyte (KiB), mebibyte (MiB) β but adoption remains inconsistent.
Binary and Other Number Bases
Binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16) are different ways to represent the same numbers. Programmers use hex because each hex digit maps to exactly four bits, making it a compact way to write binary:
| Binary | Decimal | Octal | Hex |
|---|---|---|---|
| 0000 | 0 | 0 | 0 |
| 0001 | 1 | 1 | 1 |
| 0101 | 5 | 5 | 5 |
| 1010 | 10 | 12 | A |
| 1111 | 15 | 17 | F |
| 11111111 | 255 | 377 | FF |
This is why hash outputs are displayed in hex rather than binary β a SHA-256 digest is 256 bits, which is 64 hex characters instead of 256 binary digits.
Two's Complement β How Computers Store Negative Numbers
Computers represent negative integers using two's complement. To negate a number: flip every bit and add 1. In an 8-bit system, 00000101 is +5 and 11111011 is β5. The leading bit acts as a sign indicator: 0 for positive, 1 for negative. This system has a useful property β addition works the same for positive and negative numbers, so the processor does not need separate circuits for subtraction.