Binary to Text

Encode text to binary or decode binary to text using 8-bit ASCII encoding.

Back to all tools on ToolForge

More in Encoding & Decoding

Binary Input



Text Output

About Binary to Text Converter

The Binary to Text tool converts between human-readable text and binary (base-2) representation using 8-bit ASCII encoding. Each character is encoded as exactly 8 binary digits (bits), producing a binary string that can be decoded back to the original text.

Character Encoding Fundamentals

Text representation in computers uses standardized encoding schemes:

Encoding Bits per Char Characters Use Case
ASCII 7 bits 128 (0-127) Basic English text
Extended ASCII 8 bits 256 (0-255) European languages
UTF-8 8-32 bits (variable) 1,114,112 (Unicode) Web standard, all languages

ASCII Character Reference Table

Char Decimal Binary Hex
A 65 01000001 0x41
B 66 01000010 0x42
C 67 01000011 0x43
a 97 01100001 0x61
b 98 01100010 0x62
0 48 00110000 0x30
1 49 00110001 0x31
(space) 32 00100000 0x20
! 33 00100001 0x21
\n (LF) 10 00001010 0x0A
\r (CR) 13 00001101 0x0D
DEL 127 01111111 0x7F

Encoding Example: "Hello"

Character: H       e       l       l       o
ASCII:     72      101     108     108     111
Binary:    01001000 01100101 01101100 01101100 01101111
Hex:       0x48    0x65    0x6C    0x6C    0x6F

With spaces: 01001000 01100101 01101100 01101100 01101111
Without:     0100100001100101011011000110110001101111

Decoding Example: Binary to Text

Binary: 01001000 01101001 00100000 01010111 01101111 01110010 01101100 01100100
        |______| |______| |______| |______| |______| |______| |______| |______|
           |         |         |         |         |         |         |         |
          72       105       32        87       111      114      108      100
           |         |         |         |         |         |         |         |
           H         i               W         o         r         l         d

Result: "Hi World"

Encoding Algorithm

Converting text to binary:

  1. Get character code: For each character, get its ASCII/Unicode code point
  2. Convert to binary: Convert the decimal code to binary representation
  3. Pad to 8 bits: Add leading zeros to ensure exactly 8 bits per character
  4. Concatenate: Join all 8-bit groups with optional spaces
JavaScript Implementation:

function encodeToBinary(text, withSpaces) {
  const separator = withSpaces ? ' ' : '';
  let result = '';

  for (let i = 0; i < text.length; i++) {
    // Get character code
    const code = text.charCodeAt(i);

    // Convert to 8-bit binary
    const binary = code.toString(2).padStart(8, '0');

    // Append with separator
    result += (i > 0 ? separator : '') + binary;
  }

  return result;
}

// Example: encodeToBinary("Hi", true)
// 'H' = 72 = 01001000
// 'i' = 105 = 01101001
// Result: "01001000 01101001"

Decoding Algorithm

Converting binary back to text:

  1. Remove spaces: Strip all whitespace from the binary string
  2. Validate length: Ensure length is divisible by 8
  3. Split into bytes: Divide into 8-bit groups
  4. Convert each byte: Parse binary to decimal, then to character
  5. Concatenate: Join all characters to form the result string
JavaScript Implementation:

function decodeBinary(binary) {
  // Remove all whitespace
  const clean = binary.replace(/\s+/g, '');

  // Validate length
  if (clean.length % 8 !== 0) {
    throw new Error('Invalid length: must be multiple of 8');
  }

  // Validate characters
  if (/[^01]/.test(clean)) {
    throw new Error('Invalid character: only 0 and 1 allowed');
  }

  // Decode each byte
  let result = '';
  for (let i = 0; i < clean.length; i += 8) {
    const byte = clean.slice(i, i + 8);
    const code = parseInt(byte, 2);
    result += String.fromCharCode(code);
  }

  return result;
}

// Example: decodeBinary("01001000 01101001")
// "01001000" = 72 = 'H'
// "01101001" = 105 = 'i'
// Result: "Hi"

Common Binary Patterns

Binary Decimal Character Description
00000000 0 NULL Null terminator
00001010 10 LF Line feed (newline)
00001101 13 CR Carriage return
00100000 32 (space) Space character
00110000 48 0 Digit zero
01000001 65 A Uppercase A
01100001 97 a Lowercase a
01111111 127 DEL Delete character

Applications of Binary Encoding

How to Convert Binary to Text

Decode Binary to Text

  1. Paste binary: Enter your binary string (spaces between bytes are optional).
  2. Click Decode: The tool converts each 8-bit group to its ASCII character.
  3. View result: The decoded text appears in the output box.
  4. Copy output: Click "Copy Result" to use the decoded text elsewhere.

Encode Text to Binary

  1. Enter text: Type or paste the text you want to encode.
  2. Choose format: Check "Space between bytes" for readable output with spaces.
  3. Click Encode: Each character is converted to its 8-bit binary representation.
  4. Copy output: Click "Copy Result" to use the binary string elsewhere.

Tips

Frequently Asked Questions

How does text become binary?
Text is converted to binary using character encoding standards. Each character maps to a numeric code (ASCII value), which is then represented in binary. For example, 'A' has ASCII code 65, which is 01000001 in 8-bit binary. Standard ASCII uses 7 bits (0-127), while extended ASCII and UTF-8 use 8 bits per character.
What is ASCII encoding?
ASCII (American Standard Code for Information Interchange) is a 7-bit character encoding standard that defines 128 characters: uppercase and lowercase English letters (A-Z, a-z), digits (0-9), punctuation marks, and control codes. Each character is assigned a unique number from 0 to 127.
What is the difference between ASCII and UTF-8?
ASCII uses 7 bits for 128 characters (English only). UTF-8 is a variable-length encoding that uses 1-4 bytes per character. ASCII characters (0-127) are encoded identically in UTF-8 using 1 byte, making UTF-8 backward compatible with ASCII. UTF-8 supports all Unicode characters including accented letters, Chinese, Japanese, Arabic, etc.
Why is binary length required to be a multiple of 8?
Each character in 8-bit encoding requires exactly 8 binary digits (1 byte). If the binary string length is not divisible by 8, it indicates incomplete or corrupted data. For example, 'Hi' = 2 characters = 16 bits = 01001000 01101001. A 15-bit or 17-bit string cannot be properly decoded.
What are control characters in ASCII?
Control characters (ASCII 0-31 and 127) are non-printing codes originally designed for teletype control. Common ones include: NULL (0), LF/Line Feed (10), CR/Carriage Return (13), ESC (27), DEL (127). These control cursor movement, device operations, or have special meaning in protocols.
How do I convert binary to hexadecimal?
Group binary digits into 4-bit nibbles, then convert each to hex: 0000=0, 0001=1, ..., 1001=9, 1010=A, 1011=B, 1100=C, 1101=D, 1110=E, 1111=F. Example: 01001000 = 0100 1000 = 4 8 = 0x48 = 'H' in ASCII.