Binary to text (ASCII)

Here you can convert binary to text. The translation will convert the binary code to decimal and then use the ASCII table to represent the characters behind those decimal codes.
Below you can learn how to do the conversion yourself and even how to implement such converter using the C programming language.

Convert binary to text

Advertise on this site. I promise you will like the rates :)

To generate binary code from ASCII text use the text to binary converter.

Auto format the input

How the conversion works?

Computers represent the information, using numbers. Every symbol has a distinct numeric code. The mechanism of symbol representation is called character encoding.
One popular encoding is ASCII. We will use the ASCII table to map the binary octets to characters. Before we can do the translation, we need to convert the input from binary number system to decimal.

To do the conversion, we need to do several tasks:

  1. Validate the input
  2. Format the input text if necessary. This helps the further actions.
  3. Take the binary digits(bits) in groups of 8. We call these groups “octets”.
  4. Convert each octet to its decimal code.
  5. Translate each decimal code to its symbol from the ASCII table.

Here is an example:


  1. The input contains only 0s and 1s. This is a valid binary code, so the validation is OK.
  2. For this example, it will be easier if we separate each octet with a space:
    01000001 01000010 01000011
  3. In this case we did this step in 2.
  4. Convert the octets to their decimal:
    01000001 = 65
    01000010 = 66
    01000011 = 67
  5. 65 = A, 66 = B, 67 = C

    010000010100001001000011 = ABC

Binary alphabet

Using the binary alphabet we can make the above conversion easier. Let's say, that for some reason you convert binary to text on paper. We can skip step 4 and directly map the binary value to its ASCII symbol. For this, we need a table to look up the mappings. We can call this table our binary alphabet.
In this mapping we will add the English letters (both capital and lowercase) and several other symbols that could be useful – space, comma, dot...

Capital Letters
A 01000001 H 01001000 O 01001111 V 01010110
B 01000010 I 01001001 P 01010000 W 01010111
C 01000011 J 01001010 Q 01010001 X 01011000
D 01000100 K 01001011 R 01010010 Y 01011001
E 01000101 L 01001100 S 01010011 Z 01011010
F 01000110 M 01001101 T 01010100
G 01000111 N 01001110 U 01010101

Lowercase Letters
a 01100001 h 01101000 o 01101111 v 01110110
b 01100010 i 01101001 p 01110000 w 01110111
c 01100011 j 01101010 q 01110001 x 01111000
d 01100100 k 01101011 r 01110010 y 01111001
e 01100101 l 01101100 s 01110011 z 01111010
f 01100110 m 01101101 t 01110100
g 01100111 n 01101110 u 01110101

Other symbols
(space) 00100000
! 00100001
" 00100010
' 00100111
, 00101100
- 00101101
. 00101110
: 00111010
; 00111011
? 00111111

For other symbols from the binary alphabet you can use the text to binary converter.

Write your own binary to text converter

In this implementation we will use the function from the binary to decimal conversion lesson.
The example implementation (free download: also has validation and formatting. We will not go into details there. Instead we will keep focus on the conversion itself.
The code is also available on Git Hub.

int main(void)
    char binary[559];
    char *text;
    int binaryLength, symbolCount;
    scanf("%558[^\n]s", binary);
    binaryLength = strlen(binary);
    symbolCount = binaryLength / 8 + 1;
    text = malloc(symbolCount + 1);
    binaryToText(binary, binaryLength, text, symbolCount);
    printf("The result text is: %s\n", text);
    return 0;

We aim to convert up to about 500 binary digits to ASCII. 496 is the closest multiple of 8, so that is the biggest binary size that we will handle. This is enough to encode 62 ASCII symbols. The input could contain one space between the octets so we allocate 496 + 62 + 1(null terminator) = 559 bytes.

By default, scanf will scan for a string until the first whitespace. This means that if we enter the 01000001 01000010, it will read only the first octet. To avoid this, we use the special formatter [^\n]. This tells scanf to read until it reads the new line symbol (the return key).

Then we allocate the necessary memory for the result text and start the conversion:

void binaryToText(char *binary, int binaryLength, char *text, int symbolCount)
    int i;
    for(i = 0; i < binaryLength; i+=8, binary += 8)
        char *byte = binary;
        byte[8] = '\0';
        *text++ = binaryToDecimal(byte, 8);
    text -= symbolCount;

Once we have the input in the correct format, the conversion is very simple. We take each octet, convert it to its decimal representation and save the resulting code. As we said earlier, we use the binaryToDecimal function, that we created in another lesson.

One thing to look for, is to count the number of symbols. We need that count, so we can reset the pointer to the first symbol.
Now the binary to text conversion is finished. We can print the result and free any memory that we allocated on the heap with the malloc function above.

Testing our program, we need to enter a binary input that will translate to visible characters, so we can verify that it is working as expected.
I used the ABC code from above 010000010100001001000011:

You can also do the reverse conversion. To see how it is done go to text to binary lesson.

   Search this site: