Skip to main content

bin2hex

Convert binary data to hex strings and hex back to binary at the byte level β€” like PHP's bin2hex() and hex2bin().

Input
0 chars | 0 bytes
Encode
Output
0 chars | 0 bytes

The `bin2hex` operation β€” converting raw binary bytes to their hexadecimal string representation β€” is a fundamental operation in systems programming, cryptography, and network protocol work. It is how you print a byte array in a debugger, how you display a cryptographic hash, and how you serialise binary data for storage in a text field or transmission in a JSON payload.

This tool converts binary data (entered as raw text, where each character is treated as its byte value) to a hex string, and reverses the process to convert a hex string back to binary. It operates at the byte level, making it the right tool for working with file signatures, hash values, binary protocol fields, and any situation where you need to inspect or construct the exact byte-level content of a value.

How to Use bin2hex Online

  1. 1

    Paste Hex or Binary Input

    Paste a hex string to see the binary byte representation, or paste hex-encoded bytes to view as a formatted hex dump.

  2. 2

    Inspect Byte-Level Data

    Each byte is shown as two hex digits. The tool auto-warns if an odd number of hex characters are entered and left-pads with a zero.

  3. 3

    Copy the Result

    Copy the hex or binary output for use in code, protocol debugging, or CTF challenges.

How bin2hex Conversion Works

At the byte level, bin2hex is straightforward: each input byte is formatted as exactly two hex digits, zero-padded on the left if necessary, and the results are concatenated. The byte value 0 becomes `00`, 10 becomes `0a`, and 255 becomes `ff`. The output length is always exactly twice the input length in bytes β€” a predictable property that makes hex strings easy to work with programmatically: you can always extract byte N from a hex string by taking characters at positions `2N` and `2N+1`.

The reverse operation (hex-to-binary) splits the hex string into two-character groups, parses each as a base-16 integer, and emits the corresponding byte. Error handling is important: an odd-length hex string, a character outside `0-9a-fA-F`, or a value above `0xFF` in a group all indicate malformed input that must be rejected rather than silently truncated.

Why Use FileCrank bin2hex?

  • βœ“ Byte-level hex conversion matching PHP bin2hex() / hex2bin() behavior.
  • βœ“ Warns and corrects odd-length hex input automatically.
  • βœ“ Useful for protocol payloads, cryptographic output, and CTF challenges.
  • βœ“ Runs entirely in your browser β€” no data sent to any server.

Features & Specs

Max File Size
Up to 100 MB
Privacy
Files deleted after about an hour
Price
Free, no signup
Processing
100% client-side
Your data never leaves your browser β€” all processing is local.No account or signup required.Free with no usage limits.

Frequently Asked Questions

What is the difference between bin2hex and the hex converter?

The hex converter converts human-readable text strings to and from hex. bin2hex converts raw byte data β€” binary protocol payloads, file bytes, cryptographic output β€” which may not form valid text. Use bin2hex for byte-level inspection.

What does PHP's bin2hex() function do, and can I replicate it here?

PHP's bin2hex() takes a binary string and returns a hexadecimal string where each byte is represented as two hex digits. This tool replicates that behavior. The string 'A' (ASCII 65 = 0x41) encodes to 41.

Why does entering an odd number of hex characters cause a warning?

Hex encoding always represents complete bytes β€” each byte is exactly two hex characters. An odd number means the first byte is incomplete. The tool left-pads with a 0 and shows a warning so you know the input was adjusted.

Is this tool useful for CTF challenges?

Yes. Many CTF challenges involve hex dumps, binary payloads, and encoding layers. This tool handles byte-level hex conversion quickly in the browser without requiring local tools.

bin2hex vs. xxd vs. Python binascii

Python's `binascii.hexlify()` and `bytes.hex()` are the idiomatic in-code solution but require a script or REPL. The `xxd` command produces a formatted hex dump with address offsets and ASCII representation in columns β€” excellent for file inspection but verbose for extracting a single hex value. A browser-based bin2hex tool is the fastest option when you have a short binary string or hash value and need its hex form (or vice versa) right now, without writing code or opening a terminal.

FileCrank bin2hex converts between binary data and hexadecimal strings at the byte level, replicating PHP's bin2hex() and hex2bin() functions, entirely in your browser.

Advertisement

Ad