The same input, five answers
Take the 32-bit value 0x0A0B0C0D and ask five people to reverse it. You get five files back, and only one of them loads.
| Operation | Result | Where it belongs |
|---|---|---|
| Byte order | 0D0C0B0A | Endian swaps between x86 memory and a file or wire format |
| Bits in each byte | 50D030B0 | LSB-first serial links, CRC reflection, some bitmap rows |
| Nibbles in each byte | A0B0C0D0 | Packed BCD and telecom fields that store digit pairs swapped |
| Every bit, end to end | B030D050 | Reversing a bit field that crosses byte boundaries |
| Hex digits as text | D0C0B0A0 | Puzzles and string exercises, almost never binary data |
Four of those change the numeric value. One of them, the nibble swap, changes it too. Nothing here is a formatting tweak, so knowing which operation you asked for matters more than the output looking neat.
Byte order is what people mean by endianness
A 32-bit integer holds four bytes. The processor decides which end of memory the low byte sits at, and the two conventions have never agreed.
Write 0x0A0B0C0D to memory on any x86 or ARM machine running little-endian and a hex dump shows 0D 0C 0B 0A. The same value written by a big-endian machine, or by anything following network byte order, reads 0A 0B 0C 0D straight across.
uint32_t v = 0x0A0B0C0D;memory: 0D 0C 0B 0A
Low byte first, what your debugger prints
htonl(0x0A0B0C0D)wire: 0A 0B 0C 0D
High byte first, what the protocol spec shows
So a value that reads backwards in a packet dump usually needs a byte swap, not a digit swap. Set the group size to 4 bytes and the whole buffer flips one word at a time instead of end to end, which is the difference between fixing a header and destroying it.
GUIDs flip only part of themselves
A Microsoft GUID is the sharpest example of a partial swap. The text form 3F2504E0-4F89-11D3-9A0C-0305E82C3301 stores its first three fields little-endian and the last two big-endian, so on disk it reads E0 04 25 3F 89 4F D3 11 9A 0C 03 05 E8 2C 33 01.
Reverse all sixteen bytes and you get a value nothing recognises. The fields have to be swapped at 4, 2, and 2 bytes, with the final eight left alone. Load the GUID sample, work one field at a time, and watch what a whole-input reversal does to it by comparison.
Reversing the digits is not a byte swap
This is the mistake worth naming, because the two operations look similar in a text editor and produce different bytes.
Reversing the characters of 0A0B0C0D gives D0C0B0A0. Reversing the bytes gives 0D0C0B0A. Both are eight hex digits, both look plausible, and only the second one is the little-endian encoding of the original number.
The reason is arithmetic. Reversing the text moves each nibble as if it were an independent unit, so a byte written 0D comes out as D0, which is 208 rather than 13. A text reversal is a byte reversal with a nibble swap glued on top, and that extra step is what breaks the value.
The tell is a leading zero. Bytes below 0x10 are written with one, and a text reversal pushes that zero to the wrong side of the pair every time.
Bit reversal belongs to hardware
Reversing the eight bits inside a byte has nothing to do with endianness. It comes up wherever a wire sends bit 0 of each byte first, ahead of bit 7.
- UART frames shift out LSB first. A byte captured on a logic analyser set to MSB first arrives mirrored.
- SPI peripherals usually clock MSB first, with an LSB-first bit in the control register. Two devices on one bus disagreeing on that setting produce bytes that read mirrored on the scope while every wire looks correct.
- CRC reflection is the same idea in software. The CRC-32 used by zlib, PNG, and gzip reflects its input and output, which is why the polynomial
0x04C11DB7appears in reflected implementations as0xEDB88320. Those two numbers are a bit reversal of one another, and you can check that here in a second. - Monochrome bitmaps sometimes pack the leftmost pixel in bit 0 rather than bit 7, so an image that renders mirrored in one viewer is a bit order mismatch.
A single byte makes the pattern obvious. 0xA3 is 10100011. Read the bits the other way and you get 11000101, which is 0xC5.
Nibble swaps and packed digits
A nibble is four bits, one hex digit. Swapping the two nibbles in a byte turns 0x12 into 0x21 and leaves the byte count untouched.
The format that needs this is packed BCD, where each nibble holds a decimal digit. Phone numbers in GSM SMS PDUs are stored as semi-octets with the digit pairs swapped, so a number ending in an odd digit gets padded with F. Older smart card and point of sale protocols do the same thing with dates and amounts.
Outside those formats a nibble swap is rarely what you want. If your data looks scrambled inside each byte but the byte sequence seems right, try the nibble swap before assuming the file is corrupt.
Group size changes the answer
Reversal without a boundary treats the input as one long value. That is correct for a single integer and wrong for an array of them.
Take eight bytes holding two 32-bit integers, 0D0C0B0A 1A2B3C4D. Reversed across the whole input, the two integers trade places and each is swapped, which is usually not what you asked for. Reversed in 4 byte groups, each integer flips in place and stays where it belongs.
0D0C0B0A1A2B3C4D 4D3C2B1A0A0B0C0D
Order of the two values swapped as well
0D0C0B0A 1A2B3C4D 0A0B0C0D 4D3C2B1A
Each value flipped in place
When the byte count is not a multiple of the group size, the trailing partial group is reversed within itself and flagged. Real structures do not have ragged tails, so that flag almost always means the input is missing bytes or carries a header the grouping should skip.
An odd number of hex digits is ambiguous
Hex arrives in pairs because a byte is two digits. Paste ABC and there is no way to tell whether you meant the number 0x0ABC or the bytes AB C0.
Padding on the left treats the input as a number, which is right when you copied a value out of a calculator or a register view. Padding on the right treats it as a truncated stream, which is right when you copied from a dump and lost a character. The choice is yours, and the flag stays visible so the padding never happens quietly.
What this page will not do
- It does not guess your intent. Nothing here inspects the data and decides an endian swap was meant. Pick the operation yourself, because the tool has no idea whether those four bytes are an integer, a float, or part of a string.
- Signed values are shown unsigned. The decimal readout reads the bytes as an unsigned big-endian integer. A value with the top bit set reads as a large positive number, not a negative one, and only up to 8 bytes.
- Text does not survive a byte reversal. ASCII happens to reverse into readable text backwards. UTF-8 does not, because reversing the bytes of a multibyte character produces a sequence no decoder accepts.
- Floats need the right width. Swapping an IEEE-754 double means reversing exactly 8 bytes. Get the group size wrong and the exponent lands in the mantissa, which yields a number rather than an error.
- This is not encryption. A reversal is trivially undone by the same operation. It hides nothing from anyone.
- Everything runs in this tab. No upload, so paste as much as your browser handles comfortably. Multi-megabyte dumps belong in
xxd,od, or a short Python script withint.from_bytes.
Checks worth running on the result
Three readouts on this page exist to catch a wrong choice before the bytes go anywhere.
The unsigned decimal pair tells you whether the number you expected appeared. A firmware magic number, a length field, a timestamp near the present day, all of them are recognisable the moment the byte order is right.
The ASCII column is the fastest check on a buffer holding text. File signatures like PK, %PDF, or the ELF tag sitting behind a 0x7F byte show up immediately, and a signature that appears at the tail rather than the head means you reversed something that was already in the right order.
The bytes that moved counter catches the quiet failure. A byte order swap on a single byte, or on a palindrome like 1A2B2B1A, changes nothing at all. Zero movement means either the operation was a no-op or the group size is 1.
Run the result through the tool a second time with the same settings. Every operation here is its own inverse, so you land back on the bytes you started with. The one exception is an odd digit count, where the padding is applied before the reversal, so the round trip returns the padded value rather than the three digits you typed.
Nearby pages
To read a hex value as a number rather than move it around, Hex to Decimal and Hex to Binary do the conversion, and binary is where a bit reversal becomes obvious to the eye. For buffers holding text, Hex to Text decodes the bytes and Text to Hex goes back. When the reversal is part of a bit level fix, Bitwise Calculator and XOR Calculator handle the masking.
