Endianness Byte-Swap Converter
Reverse the byte order of a hexadecimal value to convert between big-endian and little-endian representations.
Width
How does this calculator work?
To swap endianness, write the value as full-width bytes and reverse their order: 0x12345678 (32-bit) becomes 0x78563412. This converts between big-endian and little-endian. The operation is its own inverse, so applying it twice restores the original value. Choose 16, 32, or 64 bits to match your data.
Formula
How this is calculated
Enter a hexadecimal value and choose its width: 16, 32, or 64 bits. The value is first cleaned (an optional 0x prefix, spaces, and underscores are removed) and then zero-padded on the left to the full width, so a 32-bit input always becomes 8 hex digits (4 bytes). The string is split into w/8 bytes, each one being a pair of hex digits.
Byte swapping simply reverses the order of those bytes. For example, the 32-bit value 0x12345678 has bytes [12, 34, 56, 78]; reversing them gives [78, 56, 34, 12], i.e. 0x78563412. This is exactly the bswap operation used when moving data between big-endian and little-endian systems, since the two orderings store the most-significant and least-significant bytes at opposite ends.
The original and swapped decimal values are computed with 64-bit-safe integer arithmetic, and the per-byte mapping shows how each source byte position moves to its destination (position i goes to position n-1-i). Note that the swap is its own inverse: applying it twice returns the original value. Inputs with more hex digits than the chosen width, or with non-hex characters, are rejected.
Frequently asked questions
Big-endian stores the most-significant byte first (at the lowest address), while little-endian stores the least-significant byte first. Converting between them means reversing the byte order, which is what this tool does.
No. A byte swap is its own inverse, so swapping a value and then swapping the result again returns the original value.
Byte swapping operates on a fixed-width value. A shorter hex string is padded on the left with zeros to fill the chosen width before its bytes are reversed.
Also known as
TG we-Calculate Editorial Team. (2026). Endianness Byte-Swap Converter [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/endianness-byte-swap-converter
TG we-Calculate Editorial Team. "Endianness Byte-Swap Converter." TG we-Calculate. 2026. https://we-calculate.com/calculator/endianness-byte-swap-converter.
TG we-Calculate Editorial Team, "Endianness Byte-Swap Converter," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/endianness-byte-swap-converter
@misc{wecalculate_endianness_byte_swap_converter, title = {Endianness Byte-Swap Converter}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/endianness-byte-swap-converter}}, year = {2026}, note = {TG we-Calculate} }
Did this calculator help you?
