ExactBench · Engineering calculators

Endian · Byte Swap Converter

Big-endian ↔ little-endian

Value

Little-endian (byte-swapped)

0x78 56 34 12
from 0x12 34 56 78 · 2018915346 unsigned

Bytes in memory

4 bytes · address offset shown below each
BYTE ORDER IN MEMORYbig-endian12+034+156+278+3little-endian78+056+134+212+3
Big-endian (as entered)0x12 34 56 78
Little-endian (swapped)0x78 56 34 12
Decimal, big-endian305419896
Decimal, little-endian2018915346
Bytes in memory, big-endian12 34 56 78
Bytes in memory, little-endian78 56 34 12
16-bit word swap0x56 78 12 34
How this works. Byte order decides how a multi-byte value is laid out in memory. Big-endian stores the most significant byte at the lowest address, which is how the value reads on paper and how network protocols send it. Little-endian stores the least significant byte first, which is what x86 and ARM do in practice. Swapping is a pure byte reversal — the bits inside each byte never move. This is what htonl, __builtin_bswap32 and Modbus register order are all doing, and reading a value with the wrong order is why 0x12345678 arrives as 0x78563412.
The value entered is wider than the selected word width, so only the low bytes are shown.