Text to Binary

Converter

Convert text to binary or back via UTF-8 encoding for ASCII and Unicode characters. Handy for low-level debugging, encoding tutorials and CTF puzzles.

5 bytes
Plain Text
5 chars
Binary (UTF-8)
40 bits·5 bytes

About Text to Binary

Breaking text into a string of 0s and 1s is something you do when teaching character encoding, inspecting serial data, or running a low-level programming demo. This tool converts text to and from binary bit strings locally in your browser, encoding every character by its actual UTF-8 bytes rather than a naive one-byte-per-character approach. That matters: a common Chinese character occupies 3 bytes (24 bits) and an emoji typically 4 bytes (32 bits). Output groups every 8 bits with a space for readability, and decoding ignores whitespace, so you can paste bit strings with or without grouping. Because UTF-8 is the Web's default character encoding, it faithfully preserves any script, symbol, or emoji. The usual failure is an off-by-one: decoding needs the total bit count to be a multiple of 8, so a truncated string errors out until you notice the missing bit. Everything runs on your machine and nothing is uploaded, so private text stays safe.

Misuse centres on the encoding convention: one Chinese character is three bytes in UTF-8 and two in GBK, so the binary string differs in both length and content, and the same charset must be used to decode. Another is ignoring the separator convention, since an unbroken bit string cannot be split, which means agreeing on either fixed-width grouping or space separation, as a mismatch yields entirely wrong recovery.

Separate display from transport. Writing text as binary suits teaching and bit-by-bit inspection, but as a transport encoding it is very inefficient: eight characters per byte makes it eight times the original, against twice for hexadecimal and about one and a third for Base64. Use the latter two for actual transfer, and keep bit strings for cases that genuinely need per-bit observation or comparison with hardware and protocol documentation.

If the goal is human inspection of the bit pattern, show the hexadecimal form as well: bit strings suit per-bit comparison while hex groups four bits more compactly, and side by side they stay observable without stretching the page. If the goal is machine parsing, use a byte array or hex string instead, since bit strings need an extra parsing step and are error-prone in agreeing on group width.

A final premise is the readability cost: bit strings are long and humans readily misread 0 and 1, especially in long runs. Verify such content by grouping the bits alongside hexadecimal, or simply compare a checksum for the whole block rather than inspecting bit by bit. Replacing per-bit comparison with a digest of the block is the more reliable method here.

Both directions must be used as a pair, and more strictly than it seems. If the grouping differs between encoding and decoding the result is entirely different: the same bits read in groups of eight or four yield two unrelated sets of characters. Document the convention and run a smoke test with a known input on the receiving side to confirm encoder and decoder agree.

As a notation it solves the same problem as hexadecimal and escape sequences — writing bytes as readable characters — differing only in compactness and directness. Choose by purpose rather than prestige: bit strings for per-bit inspection, hex or an encoding format for compact transport, escapes or encoded text for embedding binary in text. Sorting out the three scopes prevents using the most verbose one for transfer.

In teaching and documentation the bit string has an irreplaceable advantage: a reader can see directly what a flag or mask does. When a protocol document says the third bit means something, a bit string maps onto that sentence more readily than hex does. So even where it is unsuitable for transport it remains valuable for explanation, provided its role is explaining rather than transferring.

With long text, expect the size to balloon: eight characters per byte turns ten thousand characters into eighty thousand, which is unwieldy to paste or compare. For a check, take the first and last few bytes only; for a full conversion, export to a file rather than leaving it on screen, since copying is itself error-prone.

Finally, verification: comparing bit strings by eye almost always introduces mistakes, and long runs of identical zeros and ones are the hardest to read. Verify by comparing a digest of the whole block, or confirm the content in hexadecimal first and then convert. Replacing human comparison with a digest is the habit most worth adopting for this kind of data.

How It Works Internally

Conversion writes each character as the binary bit string of its encoded bytes, so the encoding is decisive: one Chinese character is three bytes in UTF-8 and two in GBK, giving different length and content. Decoding must use the same character set and the same separator convention, or the recovered text is entirely wrong.

InputThe character A (UTF-8)
Output01000001 (one byte, decimal 65); a Chinese character such as 中 spans three bytes, 24 bits

Measured on This Page

Correct encodingHello → 01001000 01100101 …; Chinese uses 3 bytes/char and emoji 4 — identical to Python's UTF-8 bytes
Fixed: invalid bytesThe old build used a non-fatal TextDecoder, so invalid UTF-8 silently became U+FFFD replacements (11111111 → replacement glyph) and the user saw question marks without knowing the original was lost. Now it reports an error suggesting a byte-length check
Round-tripChinese binary → text restores 中文 (valid sequences unaffected)
Byte displayEight bits per byte, space-separated, easy to verify by hand or paste elsewhere

Byte lengths are the debugging anchor: 49 bits is impossible because bytes come in eights, while 6 bytes for two Chinese characters is exactly right (3 each). A single stray space is harmless (it is stripped before parsing), a single missing bit is not. Since 2026-10-30 decoding failures are loud: replacements are never written silently, so a mis-split sequence surfaces as an error naming UTF-8 rather than as question marks you might paste back into a document and only notice much later.

How this was measured: Three UTF-8 round-trips (ASCII / Chinese / emoji) compared bit for bit against Python's encoded bytes, plus non-UTF-8 byte handling (0xFF 0xFF) and a Chinese round-trip, before and after the fix. · Measured 2026-10-30

How to Use

  1. Open "Text to Binary"
  2. Switch to "Text → Binary"
  3. Type text to get UTF-8 bytes as 0/1 groups
  4. Reverse the direction to decode a bit string
  5. Click the copy icon to take the bit string

Use Cases

  • Teaching demo — Show how a sentence becomes a 0/1 sequence to explain how computers store text.
  • Encoding check — Inspect a character's UTF-8 bytes to confirm the encoding is as expected.
  • Restore data — Convert a captured bit string back to text to read content from a device.
  • Protocol debug — Turn a test string into binary to compare the underlying bit sequence.
  • Fun steganography — Encode a short message as a 0/1 string for puzzles or playful sharing.
  • Bit-level debugging — Convert a byte sequence to binary to inspect individual bits when debugging a protocol buffer or serial packet.
  • CS fundamentals — Demonstrate UTF-8 encoding by showing how each character's code point maps to its binary representation.

FAQ

How many bits is one Chinese character?

Under UTF-8 a common Han character is 3 bytes, i.e. 24 bits. The tool emits bits matching each character's actual UTF-8 byte count, not a fixed one byte per character.

Do bit groups need spaces?

For readability it groups every 8 bits (one byte) with a space by default. On decoding it ignores spaces, so input works with or without them.

Must groups be 8 bits?

It works in bytes (8 bits). If the bit count is not a multiple of 8, decoding fails to align bytes and errors — check the bit string is complete.

Are emoji supported?

Yes. An emoji is usually 4 bytes in UTF-8, expanded to 32 bits and decoded back correctly.

How does this differ from text to Unicode?

This outputs byte-based 0/1 bits; to see each character's code point (like U+4F60), use our text to Unicode tool.

Why UTF-8 and not ASCII?

ASCII covers only 128 basic characters and cannot encode Chinese or emoji; UTF-8 is the default encoding of the Web and JSON, so the tool uses UTF-8 bytes to preserve any character.

My output differs from other tools (8-bit vs variable length)?

ASCII/UTF-8 encodes English as one 8-bit byte, while non-ASCII characters take 2–4 UTF-8 bytes. Some tools emit fixed 16/32-bit code points, others variable UTF-8. Align the encoding on both sides before comparing.

Converting binary back gives mojibake — why?

Usually an encoding mismatch: UTF-8 encoded Chinese decoded as ASCII/latin1 garbles. Encode and decode with the same charset. Losing leading zeros (e.g. treating groups as numbers) also breaks the 8-bit grouping.