Text to binary converter

Turn text into binary, hexadecimal, decimal or octal codes and decode them back to text. It uses UTF-8 bytes, so ASCII, accents and emoji all work. Free, and your text never leaves your browser.

How to use it

  1. Type your text, or paste the codes, in the box.
  2. Pick the Format (binary, hexadecimal, decimal or octal) and the Separator between bytes.
  3. Leave Direction on automatic, or force Text to code or Code to text.
  4. Click Copy to use the result.

Complete guide to converting text to binary, hex and decimal

What this converter does and why you might need it

Computers store every piece of text as numbers. This tool shows you those numbers: it turns text into binary, hexadecimal, decimal or octal codes, and it turns such codes back into readable text. Students use it for computer science homework, teachers prepare examples of how data is stored, developers inspect what bytes a string really contains, and many people simply enjoy sending a message in binary. It is also a quick way to see why an accented letter or an emoji behaves differently from a plain letter in a database or a file.

Remember that this is an encoding, not encryption. Anyone can decode binary or hex in seconds, so it protects nothing.

How text becomes bytes

The tool uses UTF-8, the encoding behind almost all web pages. Each character is turned into one to four bytes, and each byte is a number from 0 to 255. Basic letters, digits and punctuation, the old ASCII range, take exactly one byte. Accented letters take two, symbols such as the euro sign take three, and emoji take four.

Take the capital letter A, which is the number 65. In binary, the eight positions are worth 128, 64, 32, 16, 8, 4, 2 and 1. Since 65 is 64 plus 1, the bits are 01000001. The same byte in other formats:

FormatDigits per byteLetter APrefix accepted when decoding
Binary8010000010b
Hexadecimal2410x
Decimal1 to 365none
Octal31010o

Binary, hexadecimal and octal are padded with zeros to a fixed width so every byte has the same length. Decimal is not padded. Lowercase letters differ from capitals by 32, so a is 97, or 01100001.

Worked example: encoding

  1. Type Hello in Text or encoded bytes. The text is not made of valid codes, so automatic detection encodes it.
  2. With Format on Binary and Separator between bytes on Space, the result is 01001000 01100101 01101100 01101100 01101111.
  3. Change Format to Hexadecimal and tick Uppercase hex letters: 48 65 6C 6C 6F. Without the tick, the letters come out lowercase.
  4. Choose Decimal and Comma: 72, 101, 108, 108, 111. Choose Octal: 110 145 154 154 157.

The Details box shows the direction, the number of bytes and the number of characters. For Hello both counts are 5. For Olá there are 3 characters but 4 bytes, because the á takes two. Its hexadecimal form is 4F 6C C3 A1. The euro sign is the three bytes E2 82 AC, and a grinning face emoji is F0 9F 98 80.

Worked example: decoding

Paste 01001000 01100101 01111001 with Format on Binary. Automatic detection sees three well-formed 8-digit groups that decode to readable text, so the answer is Hey and the Details box says Code to text. Codes may be separated by spaces, commas, semicolons, pipes, hyphens or line breaks. Prefixes such as 0x48 0x69 are accepted.

Direction and separators

  • Detect automatically is cautious. Binary needs groups of exactly 8 digits, and hexadecimal, octal and decimal need at least two codes. A hex string such as 48656c6c6f with no separators is not decoded automatically, and neither is be ad, because it would not form valid UTF-8 text. When the input is ambiguous it is treated as plain text and encoded.
  • Choose Code to text to force decoding. Then 4869 in hexadecimal gives Hi, because the digits are split into groups of 2. The group sizes are 8 for binary and 3 for octal. Decimal always needs separators.
  • Choose Text to code to force encoding, for example when you want the codes of a text that happens to look like binary.
  • Separator between bytes offers Space, Comma (written with a space after it), New line or None. A line break inside your text is a byte too, so Hi and Ok on two lines include 0a in hex between them.

Errors and how to fix them

  • Not a valid code for this format: a group contains a digit that does not belong, such as 0102 in binary, or a letter outside 0 to 9 and a to f in hex. Check that the Format matches your codes.
  • Without separators, the length must be a multiple of 8, 2 or 3 digits: you pasted a run of digits with one missing or extra.
  • These bytes are not valid UTF-8 text: the numbers are valid, but they do not form characters. Example: hex ff alone. A decimal value above 255 is also rejected.

Tips

  • Hex is the format programmers read most easily, since two digits equal one byte.
  • If a decoded result looks like strange symbols, the codes probably came from another encoding, not UTF-8.
  • To convert a single number between bases, such as 255 to FF, use the number base converter. For binary-to-text safe transport in email or JSON, the Base64 encoder is the usual choice.

Related tools

See the dots and dashes alternative in the Morse code translator, or flip your text with the text reverser.

Questions

Is it ASCII or UTF-8?

UTF-8, which matches ASCII for basic letters, digits and symbols (one byte each). Accented letters, other alphabets and emoji take two to four bytes, so they produce several codes.

How are the codes written?

Binary uses 8 digits per byte, hexadecimal 2, octal 3 and decimal 1 to 3. For example, "A" is 01000001, 41, 65 or 101 depending on the format.

How does automatic detection work?

If the input is made of well-formed codes for the chosen format and decodes to readable text, it is decoded. Otherwise it is encoded. Short or ambiguous input can be misjudged, so choose the direction yourself when in doubt.

Can I decode codes with no separator?

Yes, in binary, hexadecimal and octal, if you choose Code to text. The digits are split into groups of 8, 2 or 3. Decimal needs separators. Prefixes such as 0x are accepted.