Embedded Calculators & Part Finder
Size a value with 64 free calculators, then find the real component that fits — in stock, at the best price. For MCU, power, RF & firmware. No account.
Endianness & Byte Swapping Converter
Convert and visualize hexadecimal strings across Big-Endian, Little-Endian, and Mid-Endian formats with byte alignment validation.
Endianness refers to the sequential order in which bytes of data are stored in computer memory.
Formulas & Swaps:
- Big Endian (ABCD): Most significant byte is stored at the lowest memory address.
- Little Endian (DCBA): Least significant byte is stored at the lowest memory address (common in ARM Cortex-M, x86).
- Mid-Little Endian (BADC): Swaps adjacent pairs of bytes (half-word swap).
- Mid-Big Endian (CDAB): Swaps 16-bit half-words within a 32-bit word.
Usage: Type a hex sequence. The tool will parse, pad it to byte alignment, decompose it into a visual byte array block, and output the swapped representations instantly.
When you need it: Exchanging multi-byte values between a little-endian MCU and a big-endian ("network order") protocol, or reading a sensor that ships its data MSB-first.
Worked example: 0x12345678 in little-endian memory is the byte sequence 78 56 34 12; big-endian is 12 34 56 78. A 16-bit swap is (x >> 8) | (x << 8); htonl() byte-swaps a 32-bit value on a little-endian host.
Tips & gotchas:
- Most MCUs (ARM Cortex-M, AVR, x86) are little-endian; TCP/IP and many fieldbuses are big-endian.
- Use compiler builtins like
__builtin_bswap32— they compile to a singleREVinstruction on ARM. - Only multi-byte scalar fields need swapping; byte arrays and ASCII strings are already in order.
- Bit order within a byte is a separate question from byte order — don't conflate the two.