Text to Binary Converter
Encode text as byte-by-byte binary using UTF-8, UTF-16, or Windows-1252, with a separator format you can control.
Input
Required. Up to 1,000 UTF-16 code units; spaces and line breaks are encoded as data.
UTF-8 is the recommended general-purpose choice; Windows-1252 has a limited character repertoire.
Changes only the display between 8-bit byte groups; it does not change the encoded bytes.
Result
Binary conversion
13 bytes
How to use this text to binary converter
What this calculator does
This converter turns the text you provide into the exact sequence of bytes used by the selected character encoding, then writes every byte as an 8-bit binary group. It is useful for inspecting how text is stored or transmitted, preparing reproducible encoding examples, checking byte counts, and comparing Unicode encodings with a legacy single-byte code page. It does not interpret a typed number as a mathematical integer: the text 12 is encoded as the two characters “1” and “2”. It also does not compress, encrypt, hash, or decode an existing binary payload.
The underlying model follows the byte-oriented view used by modern encoding standards. The WHATWG Encoding Standard defines UTF-8 and legacy encodings such as Windows-1252, while the Unicode Standard defines UTF-8 and UTF-16 as Unicode encoding forms.
When to use it
- Check the binary representation of a short string before placing it in documentation, a protocol test, or a programming exercise.
- Compare how the same text changes in UTF-8 versus UTF-16 LE or UTF-16 BE, especially when non-ASCII characters are involved.
- Verify whether text can be represented in Windows-1252 before working with an older Western European file or application.
- Estimate exact encoded storage for the entered string by reading the byte and bit counts alongside the binary sequence.
How to calculate
The calculator opens with a complete demonstration: Hello, world! encoded as UTF-8 with spaces between byte groups. The result is already calculated, and a validated example workbook is immediately available from Download Excel.
- Replace the demonstration in Text to encode with the exact text you want to inspect. Spaces, punctuation, and line breaks are meaningful characters and therefore produce bytes.
- Choose Character encoding. Use UTF-8 for modern interchange, UTF-16 with BOM when you specifically want a byte-order signature, UTF-16 LE or BE when the byte order is already known, or Windows-1252 for a compatible legacy Western European text stream.
- Choose a Separator. Space and comma make byte boundaries easy to read; None produces one continuous bit string. The separator changes presentation only.
- Read Binary conversion, then use Characters, Bytes, and Bits to understand the encoded size. Choose Download Excel to export the current validated state as a real XLSX workbook.
- Choose Reset to clear the demonstration and calculated data. Reset leaves the encoding and separator controls at safe defaults but removes the text, so Download Excel is disabled until a complete valid text value is entered again.
Input guide
Text to encode is a required text field. It accepts ordinary Unicode text up to 1,000 UTF-16 code units; an example is Hello, world!. The converter preserves spaces and line breaks instead of trimming them. More characters normally produce more bytes, but the exact increase depends on the encoding. A common mistake is to expect a visible character to equal one byte: accented letters, many scripts, and emoji can require multiple UTF-8 bytes. Ill-formed isolated UTF-16 surrogate code units are rejected rather than silently replaced.
Character encoding is required and accepts one of five fixed modes. UTF-8 uses one byte for ASCII and multiple bytes for many other Unicode characters. UTF-16 LE and BE encode JavaScript UTF-16 code units in the named byte order, while UTF-16 (with BOM) emits a little-endian BOM followed by little-endian UTF-16 code units. The Unicode BOM and UTF FAQ explains byte order and the role of U+FEFF. Windows-1252 uses one byte per representable character; text outside its repertoire triggers a validation error instead of being substituted.
Separator is required and accepts Space, Comma, or None. For example, the two UTF-8 bytes for “Hi” can appear as 01001000 01101001, 01001000, 01101001, or 0100100001101001. Changing this setting does not affect the byte count or bit count; it only changes the characters inserted between rendered byte groups.
Output guide
Binary conversion is an exact representation of the computed byte sequence, written with eight binary digits per byte. Characters reports Unicode code points in the entered JavaScript string; it is not a grapheme-cluster counter, so some user-perceived symbols may consist of more than one code point. Bytes is the number of encoded bytes, including the two-byte BOM when UTF-16 (with BOM) is selected. Bits is exactly eight times Bytes. Encoding confirms which character encoding produced the current result. A zero count appears only in the cleared empty state, not as a substitute for invalid input.
Worked example
With the startup text Hello, world!, UTF-8 maps the ASCII bytes to decimal values 72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, and 33. Converting each byte to eight binary digits produces:
01001000 01100101 01101100 01101100 01101111 00101100 00100000 01110111 01101111 01110010 01101100 01100100 00100001That is 13 bytes and therefore 104 bits. The MDN TextEncoder reference documents the browser API that converts JavaScript strings to UTF-8 byte arrays; this calculator uses the same UTF-8 byte semantics for that mode.
How the conversion works
The calculator first validates the input and selected encoding. It then produces a canonical byte sequence. In UTF-8, ASCII characters remain single bytes and non-ASCII code points become multibyte sequences. In UTF-16, each 16-bit code unit becomes two bytes, and supplementary Unicode characters use surrogate pairs before byte ordering is applied. Windows-1252 maps only its defined repertoire to single bytes. Finally, every byte is converted to base 2 and padded on the left to exactly eight digits.
The visible separator is applied only after the bytes are calculated. This means switching from Space to None cannot change the bytes, their order, or the reported storage size. The Excel workbook follows the same canonical model as the on-screen result, including the exact input text, encoding choice, separator choice, counts, and binary output.
Common interpretation mistakes
Binary shown here represents encoded text bytes, not the mathematical binary form of a decimal number. For example, the character “5” is UTF-8 byte 53, so its text encoding is 00110101; the integer value five is 101 in ordinary base-2 notation. Another frequent mistake is assuming UTF-16 always means big-endian or little-endian without context. The BOM mode here deliberately emits FF FE and then little-endian code units, while the explicit LE and BE modes omit a BOM. For interoperable files and protocols, follow the encoding contract of the receiving system rather than inferring byte order from appearance alone.