Reverse Hex Digits and Bytes
CU-07Paste hex values and press Reverse digits to flip them character by character, or Reverse bytes to swap their byte order, as when changing big-endian to little-endian.
Runs in your browser. Nothing is uploaded.
Hex values, one per line (0x prefix, spaces and colons between digits are allowed)
Reversed hex
How to use it
- Type or paste hex values, one per line. A 0x prefix and spaces or colons between bytes are fine.
- Press Reverse digits to flip the whole string, so 1A2B3C becomes C3B2A1.
- Or press Reverse bytes to keep each byte together and reverse their order, so 1A2B3C becomes 3C2B1A.
- Use the options for letter case, spaces between bytes and keeping the 0x prefix, then copy the result.
Digits versus bytes
Reversing digits treats the string as plain characters, so every digit changes place and the two digits of a byte get swapped too. Reversing bytes keeps each pair of digits together and flips only the order of the pairs. The second is what you want for an endianness swap: the 32-bit value 0xDEADBEEF written in the other byte order is 0xEFBEADDE. It needs an even number of hex digits, because a byte is two digits.
How input is read
Each line is one value. Spaces, underscores and colons inside a value are removed first, so ca:fe ba be is read as cafebabe. A leading 0x is allowed and kept on the result by default, and a leading minus sign is kept in front. Values are never padded: 0x1 reversed by bytes is an error, because it has one digit, not 0x01000000. Upper and lower case are kept as typed unless you choose a case.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
"abc" has 3 hex digits. Reversing bytes needs an even number (2 digits per byte); add a leading 0 if needed. | A byte is two hex digits, and the value has an odd count. | Add a leading 0, or use Reverse digits instead. |
"12G4" is not hex: "G" is not a hex digit (use 0-9 and a-f). | The value contains a character outside 0-9 and a-f. | Remove or correct the character. |
Questions people ask
How do I reverse a hex string?
Paste it and press Reverse digits to flip every character, or Reverse bytes to flip the order of the two-digit bytes. For 1A2B3C the first gives C3B2A1 and the second gives 3C2B1A. Both keep the case you typed unless you pick one.
What is the difference between reversing digits and bytes?
Reversing digits moves every character, so the two digits inside each byte also swap. Reversing bytes moves whole bytes and keeps each pair intact. For byte order work such as endianness, reverse bytes is almost always the one you need.
How do I change little-endian hex to big-endian?
Press Reverse bytes. If a 32-bit register reads 0x78563412 in little-endian order, the big-endian reading is 0x12345678. The tool just reverses the order of the bytes, so it works for any even length, not only 4 bytes.
Why do I get an error for an odd number of digits?
A byte has two hex digits, so reversing bytes needs an even count. A value like abc is not a whole number of bytes. Add a leading 0 to make it 0abc, or use Reverse digits, which has no such rule.
Does it keep the 0x prefix?
Yes, by default. A leading 0x stays at the front after reversing, and you can turn that off with the keep-prefix option. The prefix is not reversed with the digits, because it is a label and not part of the value.
About this tool
"Reverse digits" flips the string character by character, so 1A2B3C becomes C3B2A1. "Reverse bytes" keeps each pair of digits together and flips the order of the pairs, so 1A2B3C becomes 3C2B1A; that is the swap between big-endian and little-endian byte order, and it needs an even number of digits. Spaces, underscores and colons inside a value are removed first, and a leading minus sign is kept in front. A value is treated as text of hex digits, not as a number of a fixed width: it is never padded, so 0x1 reversed by bytes is an error, not 0x01000000.