String Functions
Binary to Hex Converter
Convert binary data into its hexadecimal representation, byte by byte, UTF-8 safe.
About the binary-to-hex converter
This tool converts text into its hexadecimal byte representation: each byte of the input becomes exactly two hex digits (0-9, a-f), concatenated with no spaces or separators. Type Hello and you get 48656c6c6f back — 5 characters in, 10 hex digits out, because every byte expands to two digits. The conversion runs entirely client-side in your browser; nothing you type is sent to a server or logged anywhere.
Under the hood it uses the browser's TextEncoder API to encode your input as UTF-8 bytes, then maps each byte through byte.toString(16).padStart(2, '0') and joins the results with no delimiter. Because it operates on UTF-8 bytes rather than characters, multi-byte text expands correctly: café produces 636166c3a9 — 4 visible characters but 5 bytes, since é alone takes two UTF-8 bytes. This byte-for-byte behavior matches PHP's bin2hex(), which the transform was written to mirror.
Despite the name, the input isn't a string of literal 0/1 binary digits — type 01001000 and it's hex-encoded as eight ASCII characters, not parsed as a binary number. Binary here means raw byte data, the same sense PHP uses in bin2hex(), not a sequence of digits. Reach for this when you need the exact bytes behind a string: debugging character encodings, embedding binary-safe values inside JSON or log lines, comparing hash or file output byte-for-byte, or generating hex literals for test fixtures and low-level protocol work.
Examples
Input: Hello
Output: 48656c6c6fEach of the 5 bytes becomes 2 hex digits — H=48, e=65, l=6c, l=6c, o=6f — concatenated with no separator.
Input: café
Output: 636166c3a9café is 4 visible characters but 5 UTF-8 bytes — é alone encodes to two bytes (c3 a9) — so the output is 10 hex digits, not 8.
Input: 01001000
Output: 3031303031303030The input is treated as 8 literal text characters (0 and 1), each hex-encoded by its own byte value — not read as the binary number 01001000, which actually equals 48 in hex (the same 48 as the H byte above, since binary 01001000 is decimal 72, the ASCII code for H). For real binary-number conversions, use the Base Converter tool.
Frequently asked questions
How do I convert a string to hex in JavaScript?
Encode the string to UTF-8 bytes with new TextEncoder().encode(str), then map each byte through byte.toString(16).padStart(2, '0') and join the results. That's exactly what this tool does under the hood.
Does typing 0s and 1s here convert a binary number to hex?
No — the input is always read as literal text, not as binary digits. Typing 01001000 hex-encodes the eight ASCII characters 0 and 1 themselves, producing 3031303031303030 rather than 48. For actual binary-number conversion, use the Base Converter tool instead.
How do I convert the hex back to the original text?
Use the companion Hex to Text Decoder tool, which reverses this exact operation. Programmatically that's Buffer.from(hex, 'hex').toString('utf8') in Node.js, or PHP's hex2bin().
Why is the hex output twice as long as my input?
Each byte of input becomes exactly two hex digits, so plain ASCII text always doubles in length — 5 characters become 10 hex digits. Multi-byte UTF-8 characters, like accented letters or emoji, take more than one byte each, so non-ASCII text expands by more than 2x.
Is the text I convert sent to a server?
No. The conversion runs entirely in your browser via the TextEncoder API — nothing is uploaded, logged, or stored, so it's safe to use with private or sensitive strings.