🔄

Endianness & Byte Swapping Converter

Convert and visualize hexadecimal strings across Big-Endian, Little-Endian, and Mid-Endian formats with byte alignment validation.

Inputs
ℹ Non-hex characters are stripped automatically. Odd lengths will be padded with a leading '0'.
Swapping Results
Big Endian (ABCD - Raw) —
Little Endian (DCBA - Swapped) —
Mid-Little Endian (BADC) —
Mid-Big Endian (CDAB) —
Byte Array Decomposition
💡 Usage & Formula

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 single REV instruction 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.
📖 References: Endianness (Wikipedia)