Reverse hex byte order online
This reverse hex tool swaps the byte order of hexadecimal strings, turning a big-endian value into little-endian and back again. It also offers a second mode that reverses every hex digit, for the rarer cases where you need the string mirrored nibble by nibble.
What is endianness?
A multi-byte number has to be stored in memory one byte at a time, and systems disagree on the order. Big-endian puts the most significant byte first; little-endian puts the least significant byte first. The 32-bit value 0x12345678 looks like this in each:
Big-endian: 12 34 56 78
Little-endian: 78 56 34 12
x86 processors and most ARM systems run little-endian. Network protocols such as IP and TCP send multi-byte fields in big-endian, often called network byte order. Moving data between the two means reversing bytes.
The two modes
| Input | Byte order | Every hex digit |
|---|---|---|
| 12345678 | 78563412 | 87654321 |
| 0xDEADBEEF | EFBEADDE | FEEBDAED |
| A1B2C3 | C3B2A1 | 3C2B1A |
Byte order keeps each pair of digits together and reverses the pairs; this is the endianness swap. Digit mode reverses the string one character at a time, which also swaps the two halves of every byte.
How input is cleaned
- A leading
0xis removed, and so are spaces and colons, sode ad be efand12:34:56:78are accepted. The output has no prefix or separators. - Letter case is kept as typed: lowercase in, lowercase out.
- In byte mode, an odd number of digits is padded with a leading zero, so ABC is treated as 0ABC and becomes BC0A.
- Each line is reversed on its own. Anything other than hex digits produces an error naming the line.
Practical examples
A hex dump of a little-endian file shows the bytes 78 56 34 12 for a 32-bit field. Reversing gives 12345678, and the hex to decimal converter then shows its value, 305419896.
Bitcoin is another common case: block hashes and transaction IDs are usually displayed with their bytes in the reverse of the order used internally, so comparing raw data with an explorer needs a byte swap.
Mind the field width
Byte mode reverses the whole line. If a dump contains several 32-bit values back to back, put each 8-digit value on its own line; reversing the entire run at once would also swap the order of the fields. Swapping twice always returns the original string. To inspect the bits of the result, use hex to binary, and to read hex bytes as characters, use hex to string.