{
  "id": "binary-to-text",
  "version": "7e8e1aaf2834",
  "status": "published",
  "name": "Binary to Text Converter",
  "question": "How do I convert binary to text?",
  "summary": "Reads binary code (8 bits per byte) as UTF-8 text, which includes plain ASCII.",
  "category": "convert",
  "subcategory": "number-bases",
  "url": "https://www.acalculator.org/convert/binary-to-text",
  "markdown": "https://www.acalculator.org/convert/binary-to-text.md",
  "kind": "function",
  "method": "Split the binary into bytes of 8 bits, turn each byte into a number from 0 to 255, and read the bytes as UTF-8 text.",
  "assumptions": [
    "Each byte is 8 bits, most significant bit first. A group of fewer than 8 bits between spaces is padded with 0s on the left.",
    "Spaces, commas, and any character other than 0 and 1 separate bytes.",
    "A leading byte order mark (EF BB BF) is kept as the character U+FEFF, as RFC 3629 section 6 allows.",
    "Bytes are read as UTF-8, which matches ASCII for the codes 0 to 127. A byte that is not valid UTF-8 shows as �."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "binary": {
        "title": "Binary",
        "description": "Binary code: groups of 8 bits (0s and 1s), with or without spaces between them.",
        "type": "string",
        "maxLength": 20000
      }
    }
  },
  "outputs": {
    "text": {
      "label": "Text",
      "description": "The bytes read as UTF-8 text.",
      "format": "text"
    },
    "bytes": {
      "label": "Bytes",
      "description": "How many bytes (groups of 8 bits) the binary holds.",
      "format": "integer"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "binary": "01001000 01100101 01101100 01101100 01101111"
    },
    "outputs": {
      "text": "Hello",
      "bytes": 5
    },
    "text": "The binary says \"Hello\"."
  },
  "examples": [
    {
      "given": {
        "binary": "01001000 01101001"
      },
      "expect": {
        "text": "Hi",
        "bytes": 2
      },
      "source": "hand calculation in content.mdx: 01001000 = 72 = H, 01101001 = 105 = i (ASCII); Python 3 bytes([72, 105]).decode()"
    },
    {
      "given": {
        "binary": "0100100001101001"
      },
      "expect": {
        "text": "Hi",
        "bytes": 2
      },
      "source": "hand calculation in content.mdx: the same 16 bits without a space split into two bytes"
    },
    {
      "given": {
        "binary": "11000011 10101001"
      },
      "expect": {
        "text": "é",
        "bytes": 2
      },
      "source": "RFC 3629 (UTF-8): C3 A9 encodes U+00E9; Python 3 bytes([0xC3, 0xA9]).decode(\"utf-8\") = \"é\""
    }
  ],
  "sources": [],
  "related": [
    "decimal-to-fraction"
  ],
  "changelog": []
}
