ASCII to Binary
Start from characters or from their ASCII codes, and get binary in 7-bit, 8-bit or with a parity bit. Anything that isn't real ASCII gets pointed out.
Each character and its bits
| ASCII | Decimal | Hex | Binary |
|---|
How to convert ASCII to binary by hand
Every ASCII character has a number from 0 to 127. Find the number, then write it in base 2 using seven places. The capital R is 82. Go through the place values from 64 down and take away each one that fits. A value that fits gets a 1, and one that doesn't gets a 0.
| Place value | Left over before | Fits? | Bit |
|---|---|---|---|
| 64 | 82 | Yes, leaves 18 | 1 |
| 32 | 18 | No | 0 |
| 16 | 18 | Yes, leaves 2 | 1 |
| 8 | 2 | No | 0 |
| 4 | 2 | No | 0 |
| 2 | 2 | Yes, leaves 0 | 1 |
| 1 | 0 | No | 0 |
Read the last column from top to bottom: 1010010. Put a 0 in front and you have the 8-bit byte, 01010010. For a whole word, repeat this for each character and keep them in order.
If you don't know a character's number, look it up in the full ASCII table. For dividing by 2 instead of subtracting, see decimal to binary.
Write letters and digits without the table
For letters and digits you can skip the sums. Write a fixed opening, then add a short number you already know. These are 7-bit codes.
| For a | Open with | Then add | Example |
|---|---|---|---|
| Capital letter | 10 | Position in the alphabet, 5 bits | E is 5th: 10 00101 |
| Lowercase letter | 11 | Position in the alphabet, 5 bits | e is 5th: 11 00101 |
| Digit | 011 | The digit itself, 4 bits | 5: 011 0101 |
Try your own initial. M is the 13th letter, 13 in five bits is 01101, so capital M is 1001101.
The character "42" and the number 42
ASCII converts characters one at a time. Typed as ASCII, 42 is the character 4 followed by the character 2, so you get two codes: 00110100 00110010. As a single number, 42 is 101010.
The tabs above the converter handle a third case. If your 42 is already an ASCII code, from a table or a worksheet, choose "Decimal codes". Code 42 is the asterisk, so the answer is 00101010. For the plain number, use the decimal to binary converter.
What a parity bit does
ASCII needs seven bits, which leaves one spare in a byte. Some serial links and older equipment use it to catch transmission errors. With even parity, the extra bit is chosen so the byte has an even number of 1s. With odd parity, the total comes out odd.
| Letter | 7-bit code | 1s | Even parity | Odd parity |
|---|---|---|---|---|
| A | 1000001 | 2 | 01000001 | 11000001 |
| C | 1000011 | 3 | 11000011 | 01000011 |
| E | 1000101 | 3 | 11000101 | 01000101 |
If one bit flips on the way, the count no longer matches and the receiver knows the byte is bad. It can't tell which bit changed, and two flipped bits cancel out and go unnoticed.
This converter writes the parity bit on the left, as the highest bit of the byte. A serial port sends bits in its own order and adds parity in hardware, so a setting such as "7E1" doesn't need you to add it by hand.
The characters you can't see
Spaces, tabs and line breaks have codes too, so they show up in your binary. A space is 00100000 and a tab is 00001001.
A line break depends on where the file is going. Linux and macOS use one code, LF, 00001010. Windows text files and many internet protocols use two, CR then LF, 00001101 00001010. Use the "Line breaks" setting to match. If your answer is one byte per line short of someone else's, this is the first thing to check.
Punctuation and symbols in binary
These are the space and the 32 punctuation marks and symbols in ASCII, as 8-bit bytes.
| Symbol | Code | Binary |
|---|---|---|
| space | 32 | 00100000 |
| ! | 33 | 00100001 |
| " | 34 | 00100010 |
| # | 35 | 00100011 |
| $ | 36 | 00100100 |
| % | 37 | 00100101 |
| & | 38 | 00100110 |
| ' | 39 | 00100111 |
| ( | 40 | 00101000 |
| ) | 41 | 00101001 |
| * | 42 | 00101010 |
| + | 43 | 00101011 |
| , | 44 | 00101100 |
| - | 45 | 00101101 |
| . | 46 | 00101110 |
| / | 47 | 00101111 |
| : | 58 | 00111010 |
| Symbol | Code | Binary |
|---|---|---|
| ; | 59 | 00111011 |
| < | 60 | 00111100 |
| = | 61 | 00111101 |
| > | 62 | 00111110 |
| ? | 63 | 00111111 |
| @ | 64 | 01000000 |
| [ | 91 | 01011011 |
| \ | 92 | 01011100 |
| ] | 93 | 01011101 |
| ^ | 94 | 01011110 |
| _ | 95 | 01011111 |
| ` | 96 | 01100000 |
| { | 123 | 01111011 |
| | | 124 | 01111100 |
| } | 125 | 01111101 |
| ~ | 126 | 01111110 |
Characters that look like ASCII but aren't
Word processors and phone keyboards often change what you type. A straight apostrophe turns curly, two hyphens become a long dash, or three dots shrink into a single character. They look harmless, but ASCII has no code for any of them.
The converter stops and names them instead of quietly writing different bytes. For quotes, dashes, the one-character ellipsis and non-breaking spaces, one button swaps in plain versions. Letters such as é or ñ have no automatic swap, because changing them could change a word or a name. To keep them as they are, use text to binary, which encodes them as UTF-8.
Check these before you hand in an answer
The wrong width
A worksheet that shows seven digits per character wants 7-bit. Most software expects eight. The only difference in plain ASCII is the leading 0.
Lost leading zeros
A space is 32, or 100000 in bare binary. As a 7-bit code it's 0100000. Pad every character to the full width, especially if you join them without spaces.
Capital and lowercase swapped
Q is 01010001 and q is 01110001. Your phone may capitalise the first letter without asking, so check how your text begins.
Parity you didn't want
With even or odd parity on, some bytes start with 1. A plain decoder reads those as values above 127. Choose 8-bit unless the task asks for parity.
Practice on paper
Write each one as 8-bit binary, then load it into the converter to compare. Count spaces and punctuation as characters.
Convert "Ok"
Convert "A+"
Convert "No. 7"
ASCII to binary FAQ
What is A in binary?
Capital A is ASCII code 65. It's 1000001 in 7 bits and 01000001 as a byte.
How is this different from text to binary?
This page sticks to the 128 ASCII characters and can start from their codes or add parity. Text to binary accepts any language and emoji by using UTF-8. For plain English text in 8 bits, both give the same bytes.
How many bits will my message need?
Count every character, including spaces and line breaks, then multiply by 7 or 8. With CR LF, each line break counts as two characters. The total appears under the converter.
Can I paste a list of codes?
Yes. Choose decimal or hex and separate the codes with spaces, commas or new lines. Hex codes can also be one unbroken run of pairs, such as 48656C6C6F.
How do I turn the binary back into characters?
Use binary to ASCII. It reads 7-bit and 8-bit codes. If you added parity, remove the first bit of each byte first.
Is my text sent anywhere?
No. The conversion runs in your browser, so what you type never reaches our server.