Text to binary and hex converter

The text to binary and hex converter shows the UTF-8 bytes of a text in binary, hexadecimal, octal, and decimal, and decodes a sequence of codes back to text, including non-ASCII text, such as accented letters or non-Latin scripts.
Input
To codes: plain text, up to 65,536 bytes. To text: bytes in binary, hex, octal, or decimal, separated by spaces or in one run. Up to 1 MB.

The conversion runs in the browser. Please enable JavaScript.

Everything runs in your browser; nothing is sent or stored.

  • Enter plain text or a sequence of codes in the "Text or codes" field, and click "Text to codes" or "Codes to text".
  • The result appears in separate fields for text, binary, hexadecimal, octal, and decimal, and each field has its own "Copy" button.
  • When converting to text, leave "Detect automatically" selected under "Code format when converting to text", or choose the format of the codes.
  • Under "Hex display", choose whether to show a space between bytes and whether to add the 0x prefix.
  • Above the fields, the tool shows the number of characters and the number of UTF-8 bytes, and when converting to text, also the format of the codes. In UTF-8, an English letter, digit, or space takes 1 byte, and an accented letter such as é takes 2 bytes, so text with non-ASCII characters has more bytes than characters.

From text to UTF-8 bytes

A computer stores text as a sequence of bytes, and the character encoding determines which bytes represent each character. In UTF-8, the most common encoding for websites, files, and APIs, each character is stored in 1 to 4 bytes. English letters, digits, and punctuation marks are stored in the same single byte as in the ASCII table, so English text is the same in ASCII and in UTF-8. An accented letter such as é is stored in 2 bytes, the euro sign is stored in 3 bytes, and an emoji is stored in 4 bytes. That is why a field whose length is limited in bytes, such as a database column, holds fewer characters when the text contains non-ASCII characters.

Binary, hexadecimal, octal, and decimal

A byte has 8 bits, and its value is a number from 0 to 255. The same value is written in binary as 8 digits of 0 and 1, in hexadecimal as two characters from the digits 0 to 9 and the letters a to f, in octal as three digits from 0 to 7, and in decimal as a regular number. Hexadecimal is the most common form, because every byte is written in exactly two characters. Hex editors, network traffic captures, and strings in code show bytes in hexadecimal form, such as \xc3\xa9. The octal form appears in strings in languages such as C and Python, for example \110, and the binary form is used mainly for learning and for checking individual bits.

Codes that match more than one format

The same sequence of digits can be valid in more than one format, so automatic detection is not always unambiguous. For example, the sequence 101 102 is detected as octal and converted to the letters AB, but in decimal the same sequence represents the letters ef. After converting the codes to bytes, the tool decodes the bytes as UTF-8 text, and a byte sequence that is not valid UTF-8 is shown as an error, not as garbled text.

Codes and the text that automatic detection produces from them

  • 48 69the word Hi in hexadecimal.
  • 0x48 0x69the word Hi in hexadecimal, with a prefix for each byte.
  • \x48\x69the word Hi in the form used for bytes in strings in code.
  • 01001000 01101001the word Hi in binary.
  • 72 105the word Hi in decimal.
  • C3 A9the letter é, two bytes in UTF-8.
  • E2 82 ACthe euro sign, three bytes in UTF-8.
  • 0aa line feed (LF).

Text to binary and hex converter FAQ

Why is the result different from the text I expected?

With automatic detection, a sequence in which every value has 2 digits is detected as hexadecimal, so decimal values such as 48 69 are converted to the wrong text. After you click "Codes to text", choosing a different format under "Code format when converting to text" updates the result immediately.

Why does a message say that the bytes are not valid UTF-8 text?

The message appears when the bytes were created in a different encoding, such as Windows-1252 or ISO-8859-1, in which each accented letter is stored in a single byte, for example the letter é as the byte E9. The message also appears when the bytes of a character were cut off in the middle, or when the bytes belong to a file that is not text, such as an image or a compressed file. The message shows the position of the byte where the invalid sequence starts.

Can I enter codes as one continuous sequence, without spaces?

In binary and hexadecimal, you can enter one continuous sequence, and the tool splits it into bytes of 8 digits or 2 digits, respectively. When the length of the sequence does not divide evenly into bytes, a message shows the value and its position. In octal and decimal, separate the values with a space, a line break, a comma, or a semicolon, and in octal you can also write a backslash before each value, such as \110\151.

Which prefixes does the tool accept?

The tool accepts the prefixes 0x and \x for hexadecimal, 0b for binary, and 0o or a backslash (\) for octal. You can mix values with and without a prefix in the same sequence, for example 0x48 69, and the prefix determines the format of the entire sequence.

What is the difference between the bytes of a character and its Unicode code point?

The Unicode code point is the number of the character in the Unicode table, and the bytes are the way that number is stored in UTF-8 encoding. For example, the Unicode code point of the letter é is 233 (U+00E9), and its UTF-8 bytes are C3 A9, which are 195 169 in decimal. The tool shows the bytes, and the Unicode code point is the number written in a numeric HTML entity, such as é.

What is the maximum length of text for converting to binary or hex?

When converting to codes, the text can be up to 65,536 UTF-8 bytes long. When converting to text, the input can be up to 1 MB, and the codes can represent up to 65,536 bytes.

Shopping cart

Your cart is emptyYou can start with one of our popular plans.

Site search

Accessibility

Text size
100%
Accessibility statement