bswap_32 - Linux


bswap_32 is a command-line tool used to swap the bytes of a 32-bit little-endian integer. It is commonly used in network programming, data conversion, and embedded systems development to convert between different endian formats.


bswap_32 [options] <input>


  • <input>: The 32-bit little-endian integer to be swapped.


  • -h, --help: Display help information.
  • -v, --version: Display version information.


Swap a single integer:

$ bswap_32 0x12345678

Swap multiple integers:

$ bswap_32 0x12345678 0x90abcdef 0xfedcba98
0x78563412 0xfedcba90 0x98abcdef

Common Issues

Invalid input:

If the input is not a valid 32-bit little-endian integer, bswap_32 will return an error.

Solution: Ensure that the input is a 32-bit little-endian integer in hexadecimal format.


bswap_32 can be combined with other tools for advanced tasks:

  • Endian conversion: Convert little-endian integers to big-endian and vice versa using bswap_32 -v (little-endian to big-endian) or bswap_32 --little (big-endian to little-endian).
  • Network programming: Swap byte order for network communication using bswap_32 to convert between host and network byte order.

Related Commands

  • printf
  • pack
  • unpack