Hex to Byte Array Converter
Convert a hex string such as DEADBEEF, de:ad:be:ef or 0xDE, 0xAD into a byte array, as a plain list or code for C, Java, Python, Go, Rust and more.
Paste hex in any common layout - with or without spaces, colons or 0x prefixes - and get the bytes as a list or an array declaration.
0x and \x prefixes are all fine: DEADBEEF, de:ad:be:ef, 0xDE, 0xAD.More Byte Array Tools
View all 17Each byte is exactly two hex digits, so an odd number of digits usually means a character was lost when copying.
What Is the Hex to Byte Array Converter?
It turns a hexadecimal string into a byte array. Every two hex digits are one byte. The tool accepts the formats you meet in practice - DEADBEEF, de ad be ef, de:ad:be:ef (as in MAC addresses and certificate fingerprints), 0xDE, 0xAD and \xde\xad - and writes the bytes as a list or as an array for your language.
When to Use It
- Turning a hash, key or UUID from hex into bytes for a test or a constant.
- Converting hex copied from Wireshark or a hex editor into code.
- Replacing the hand-written
bytes.fromhex()orHex.decode()call in a quick experiment.
How to Use It
- Paste the hex string - separators and prefixes are ignored.
- Choose the output language, number format, values per line and variable name.
- Copy the result.
Example
DE:AD:BE:EF:CA:FE:BA:BE as Python in hex gives data = bytes([0xDE, 0xAD, 0xBE, 0xEF, 0xCA, 0xFE, 0xBA, 0xBE]) - eight bytes.
Understanding the Output
The byte count is half the number of hex digits. Choose decimal output if the receiving code expects numbers from 0 to 255, or tick "signed" to get -128 to 127 as Java uses.
Limitations
An odd number of digits is reported as an error rather than guessed, because a missing digit usually means something was lost when copying. The tool reads a hex string; to convert a single hex number to decimal use Hex to Decimal. For the reverse direction, use Byte Array to Hex.
Frequently Asked Questions
Explore More Tools
Keep going with related categories and our most used tools.