Text to Binary Converter
This converter turns characters into 8-bit UTF-8 or ASCII bytes. If you have ASCII decimal codes rather than characters, use ASCII to Binary; for a plain number, use Decimal to Binary.
Going the other way? Convert binary back to text →
How do you convert text to binary?
Text to binary conversion replaces every character with the 8-bit binary form of its ASCII or UTF-8 code, so a two-letter word becomes two groups of eight digits.
Text to binary converts each character to its 8-bit code: "Hi" is 01001000 01101001. Look up each character's ASCII/UTF-8 code, convert that number to binary, pad it to 8 digits, and separate the bytes with spaces.
- Take the first character and look up its code. H is 72.
- Convert that code to binary by repeated division or from the table. 72 is 1001000.
- Pad the result on the left with zeros until it is 8 digits: 01001000.
- Repeat for every character and separate the bytes with a single space: Hi = 01001000 01101001.
Text to Binary Conversion Table
Every letter, digit and the space, with its code in all four bases. Find the character in the first column and read across: the Dec column is the code the method uses, and the Bin column is what this converter writes — 8 digits per character, zero-padded on the left. That column uses the digit set 0, 1 and nothing else, each place worth 2ⁿ, and a value marked with the 0b prefix means the same thing. This page writes one 8-bit zero-padded byte per character, single space between bytes. This page shows the rows you need; ASCII code chart (decimal, hex, octal, binary) carries all 128.
| Char | Dec | Hex | Oct | Bin |
|---|---|---|---|---|
| A | 65 | 41 | 101 | 01000001 |
| B | 66 | 42 | 102 | 01000010 |
| C | 67 | 43 | 103 | 01000011 |
| D | 68 | 44 | 104 | 01000100 |
| E | 69 | 45 | 105 | 01000101 |
| F | 70 | 46 | 106 | 01000110 |
| G | 71 | 47 | 107 | 01000111 |
| H | 72 | 48 | 110 | 01001000 |
| I | 73 | 49 | 111 | 01001001 |
| J | 74 | 4A | 112 | 01001010 |
| K | 75 | 4B | 113 | 01001011 |
| L | 76 | 4C | 114 | 01001100 |
| M | 77 | 4D | 115 | 01001101 |
| N | 78 | 4E | 116 | 01001110 |
| O | 79 | 4F | 117 | 01001111 |
| P | 80 | 50 | 120 | 01010000 |
| Q | 81 | 51 | 121 | 01010001 |
| R | 82 | 52 | 122 | 01010010 |
| S | 83 | 53 | 123 | 01010011 |
| T | 84 | 54 | 124 | 01010100 |
| U | 85 | 55 | 125 | 01010101 |
| V | 86 | 56 | 126 | 01010110 |
| W | 87 | 57 | 127 | 01010111 |
| X | 88 | 58 | 130 | 01011000 |
| Y | 89 | 59 | 131 | 01011001 |
| Z | 90 | 5A | 132 | 01011010 |
| a | 97 | 61 | 141 | 01100001 |
| b | 98 | 62 | 142 | 01100010 |
| c | 99 | 63 | 143 | 01100011 |
| d | 100 | 64 | 144 | 01100100 |
| e | 101 | 65 | 145 | 01100101 |
| f | 102 | 66 | 146 | 01100110 |
| g | 103 | 67 | 147 | 01100111 |
| h | 104 | 68 | 150 | 01101000 |
| i | 105 | 69 | 151 | 01101001 |
| j | 106 | 6A | 152 | 01101010 |
| k | 107 | 6B | 153 | 01101011 |
| l | 108 | 6C | 154 | 01101100 |
| m | 109 | 6D | 155 | 01101101 |
| n | 110 | 6E | 156 | 01101110 |
| o | 111 | 6F | 157 | 01101111 |
| p | 112 | 70 | 160 | 01110000 |
| q | 113 | 71 | 161 | 01110001 |
| r | 114 | 72 | 162 | 01110010 |
| s | 115 | 73 | 163 | 01110011 |
| t | 116 | 74 | 164 | 01110100 |
| u | 117 | 75 | 165 | 01110101 |
| v | 118 | 76 | 166 | 01110110 |
| w | 119 | 77 | 167 | 01110111 |
| x | 120 | 78 | 170 | 01111000 |
| y | 121 | 79 | 171 | 01111001 |
| z | 122 | 7A | 172 | 01111010 |
| 0 | 48 | 30 | 060 | 00110000 |
| 1 | 49 | 31 | 061 | 00110001 |
| 2 | 50 | 32 | 062 | 00110010 |
| 3 | 51 | 33 | 063 | 00110011 |
| 4 | 52 | 34 | 064 | 00110100 |
| 5 | 53 | 35 | 065 | 00110101 |
| 6 | 54 | 36 | 066 | 00110110 |
| 7 | 55 | 37 | 067 | 00110111 |
| 8 | 56 | 38 | 070 | 00111000 |
| 9 | 57 | 39 | 071 | 00111001 |
| (space) | 32 | 20 | 040 | 00100000 |
The base this page writes, defined by the digits it uses, how a value is marked, and what each position is worth.
| Base | Radix | Digits | Prefix | Place worth | Typical range |
|---|---|---|---|---|---|
| Binary | 2 | 0, 1 | 0b | 2ⁿ | 8-bit byte 0–255 (00000000–11111111); 4-bit nibble 0–15; 16/32/64-bit words |
Worked Example: "Hi" to Binary
One character at a time, with the working written out. This is the same grid the converter shows when you turn on "show steps".
Result: Hi = 01001000 01101001
Take the first character, H. Its code is 72. Written in binary that is 1001000, which is 8 digits only once a leading zero is added: 01001000. The place values across the top of the grid show why — 64 + 8 = 72, and every column with a 1 in it contributes its own weight.
Every remaining character repeats that same three moves: find the code, write it in binary, pad it to 8 digits. i is 105, so 01101001. The groups then join in the order the characters were typed, separated by a single space.
Nothing about the order or the count changes: one character in, one group out. That is what makes the result reversible without carrying any extra information alongside it, and it is also the quickest way to check the answer. Count the groups; there should be exactly as many as there are characters, spaces included. Then take any one group and find its row in the table above — the code in the Dec column must be the number in the Code column of the grid, and the Binary column must be the group itself. A group that comes out one digit short means a leading zero was dropped; a group count that is short means a space was trimmed off the input before the conversion ran. Those two are the only ways a correct code still produces a wrong-looking result.
Check it in reverse
The value goes back the way it came. Read 01001000 is 72, and 72 is H; read 01101001 is 105, and 105 is i. Nothing is lost on the return trip, because every character keeps one group of its own and the groups keep their order. A decoder needs no extra information from the encoder — the fixed width tells it where each group ends, and the table tells it what each code means. To verify the result by hand, decode the binary output back to text and compare it with what you started from.
Worked examples: text to binary
Each example gives the value first, then the working. Click a value to load it in the converter.
What is "Hi" in binary?
"Hi" in text is 01001000 01101001 in binary.
Method: H is code 72 = 01001000; i is code 105 = 01101001.
How do you write "I love you" in binary?
"I love you" in text is 01001001 00100000 01101100 01101111 01110110 01100101 00100000 01111001 01101111 01110101 in binary.
Method: one 8-bit group per character, spaces included (00100000).
What is the letter a in binary?
a in text is 01100001 in binary.
Method: a is code 97 = 64 + 32 + 1.
What is the letter A in binary?
A in text is 01000001 in binary.
Method: A is code 65 = 64 + 1.
What is the letter e in binary?
e in text is 01100101 in binary.
Method: e is code 101 = 64 + 32 + 4 + 1.
What is the letter b in binary?
b in text is 01100010 in binary.
Method: b is code 98 = 64 + 32 + 2.
What is the letter d in binary?
d in text is 01100100 in binary.
Method: d is code 100 = 64 + 32 + 4.
What is the letter f in binary?
f in text is 01100110 in binary.
Method: f is code 102 = 64 + 32 + 4 + 2.
What is the letter t in binary?
t in text is 01110100 in binary.
Method: t is code 116 = 64 + 32 + 16 + 4.
What is the letter g in binary?
g in text is 01100111 in binary.
Method: g is code 103 = 64 + 32 + 4 + 2 + 1.
What is the letter j in binary?
j in text is 01101010 in binary.
Method: j is code 106 = 64 + 32 + 8 + 2.
What is the letter n in binary?
n in text is 01101110 in binary.
Method: n is code 110 = 64 + 32 + 8 + 4 + 2.
What is the letter r in binary?
r in text is 01110010 in binary.
Method: r is code 114 = 64 + 32 + 16 + 2.
What is "hello" in binary?
"hello" in text is 01101000 01100101 01101100 01101100 01101111 in binary.
Method: one 8-bit group per character, spaces included (00100000).
What is a space in binary?
A space in text is 00100000 in binary.
Method: the space is code 32.
How do you write your name in binary?
"Ana" in text is 01000001 01101110 01100001 in binary.
Method: A is code 65 = 01000001; n is code 110 = 01101110; a is code 97 = 01100001.
Common phrases people convert: what binary code is · load one of these into the decoder
Every example above reverses exactly — decode the same 8-bit groups back into words.
What Changes the Binary Output?
Spaces and line breaks
A space is a character like any other: code 32, or 00100000. A trailing space converts too, which is the usual reason an output runs one group longer than expected.
Characters outside ASCII
UTF-8 encodes each character in 1 to 4 bytes. Characters 0–127 use one byte identical to ASCII, so ASCII text is valid UTF-8. Above code 127 UTF-8 uses more than one byte per character, so the byte count stops matching the character count. é is U+00E9 and encodes as C3 A9 (2 bytes); € is U+20AC and encodes as E2 82 AC (3 bytes); 😀 is U+1F600 and encodes as F0 9F 98 80 (4 bytes). Written the way this page writes them, those are é = 11000011 10101001, € = 11100010 10000010 10101100 and 😀 = 11110000 10011111 10011000 10000000. UTF-8 encoding explained sets out why.
Width and padding
ASCII defines 128 characters, codes 0–127, using 7 bits; in practice each code is stored in one 8-bit byte with a leading 0. That is why A is 01000001 here, not 1000001. Uppercase and lowercase differ by 32, which is bit 5, so a is 01100001.
Separator choice
The space between groups is a display choice; the bytes do not change. iToolHub's text-to-binary and text-to-hex converters write one 8-bit byte per character, separated by spaces. Pick no separator when the output feeds another program, a comma for a spreadsheet.
Text to Binary in Code
The same rule in one line. Both take a string and return the binary codes, space-separated.
Python: ' '.join(format(b, '08b') for b in s.encode('utf-8')) JavaScript: [...new TextEncoder().encode(s)].map(b => b.toString(2).padStart(8, '0')).join(' ') Common Mistakes
- Dropping the leading zero, so A reads 1000001 instead of 01000001. The output then splits into the wrong groups.
- Mixing widths inside one string. The first half decodes; the rest is noise.
- Pasting codes instead of characters — that is a different conversion, and it lives on convert an ASCII code (0–127) to binary.
- Forgetting that the space between words is its own group, 00100000. The counts then disagree.
Frequently Asked Questions
How do you convert a text file to binary?
Open the file, paste its contents into the box above, and convert. The result is the same as converting the text by hand: one 8-bit byte per character, every line break included.
Why does each character become 8 binary digits?
Because a byte is the unit text is stored in. A byte is 8 bits and holds 256 values, 0–255; a nibble is 4 bits. ASCII needs only 7 of those bits, so the eighth is written as a leading zero.
Can you convert emoji or non-English text to binary?
Yes. UTF-8 encodes each character in 1 to 4 bytes. Characters 0–127 use one byte identical to ASCII, so ASCII text is valid UTF-8. Above 127 a character runs to two, three or four bytes; the exact values are under "Characters outside ASCII".
Should the binary output be separated by spaces?
That is a display choice and it changes nothing. iToolHub's text-to-binary and text-to-hex converters write one 8-bit byte per character, separated by spaces. Turn the separator off when the output feeds another program.
Does a space or line break get converted to binary?
Yes, both. ASCII codes 32–126 are printable characters; 0–31 and 127 are control characters (for example 10 = line feed, 13 = carriage return, 32 = space). A space becomes 00100000.
How do you convert text to binary in Python?
Encode the string to bytes, then format each byte to 8 binary digits. The one-liner under Text to Binary in Code does exactly that and gives this page's output.
Going back the other way works the same: the same value converts straight back in the binary to text direction.
Related Conversions
The rest of the family sits on the rest of the binary converters in this family.