Binary Encoder Decoder
Treat binary as bytes first and text second. Encode Unicode text to UTF-8, decode only valid UTF-8 from complete 8-bit bytes, or inspect arbitrary binary without forcing it through a text decoder.
Decode/inspect accepts 8-bit groups separated by spaces, commas, semicolons or line breaks; 0b01000001 tokens; or one continuous bit string whose length is a multiple of eight.
Binary Has No Character Encoding Until You Choose One
11110000 10011111 10011010 10000000 is four bytes. Under UTF-8 those bytes form 🚀. In a compressed file, encrypted payload or image, the same numbers would be interpreted by a completely different format.
That distinction is why Inspect bytes is separate from UTF-8 decoding: the byte values can be examined without first asserting that the stream is text.
Complete Bytes Can Still Be Invalid UTF-8
Eight bits always make a byte, but not every byte sequence makes a UTF-8 string. Bytes C0 and C1 cannot begin legal UTF-8 characters; F5–FF are also invalid as UTF-8 lead bytes; continuation bytes 80–BF need an appropriate preceding lead byte.
Decode mode uses TextDecoder("utf-8", { fatal: true }). Malformed input therefore produces an error instead of silently turning bad bytes into replacement characters and making the original data harder to diagnose.
UTF-8 Keeps ASCII at One Byte and Expands the Rest
A “binary character” is therefore not a fixed eight-bit concept for Unicode text. UTF-8 encoding turns the string into bytes first; each resulting byte is then printed as eight binary digits.
Separated Bits Mean You Are Claiming Byte Boundaries
If you paste 01000001 01000010, the spaces say “these are two bytes.” A seven-bit or nine-bit token between separators is therefore rejected. With continuous input, the only requirement is that the total number of bits is divisible by eight.
That strictness catches a common copy/paste error where one missing bit shifts every byte that follows.
Lone UTF-16 Surrogates Need Attention Before Encoding
JavaScript strings use UTF-16 code units internally. Correct supplementary characters use a high/low surrogate pair, but broken programmatic strings can contain one half by itself. Browser TextEncoder converts lone surrogates to U+FFFD.
For diagnostics, that substitution is dangerous because it changes the data. An unpaired surrogate is reported at its UTF-16 code-unit position before UTF-8 encoding begins.
Same-Looking Text Can Produce Different Bytes
Unicode can represent some visible text in more than one canonically equivalent way. For example, é can be one code point (U+00E9) or e followed by COMBINING ACUTE ACCENT (U+0065 U+0301). Those strings can look the same while producing different UTF-8 byte sequences.
No normalization is applied before encoding, because silently changing code points would also change the bytes being inspected. When byte-for-byte equality matters for identifiers, signatures, hashes or security checks, decide on a normalization policy at the application boundary rather than assuming visual equality means binary equality.
Byte Patterns Worth Recognizing During Debugging
| Bytes | Common meaning | Why it matters |
|---|---|---|
| 00 | NUL | Invisible; can terminate strings in C-style APIs. |
| 0A | LF | Unix-style line feed. |
| 0D 0A | CRLF | Common network/Windows line ending. |
| EF BB BF | UTF-8 BOM | Can be harmless or surprise parsers expecting content at byte zero. |
Do Not Use a Text Decoder for Files Just Because They Are Bytes
PNG, ZIP, gzip, encrypted ciphertext, hashes and most protocol frames are byte sequences but not UTF-8 strings. Forcing them through text decoding can fail—or worse, appear to work after replacement characters destroy the original values.
Use Inspect mode for byte-oriented investigation. Decode mode is intentionally reserved for the stronger claim: “these bytes should be valid UTF-8 text.”
Defines the browser TextEncoder/TextDecoder APIs and the UTF-8 encoder/decoder behavior used by modern web applications.
Documents valid UTF-8 byte-sequence ranges, the preserved US-ASCII range, surrogate exclusion, BOM considerations and security issues around visually equivalent Unicode sequences.
