Skip to content

Endianness Converter

Swap byte order between big-endian and little-endian, and read the same bytes as an integer both ways. Paste a hex value to swap big-endian and little-endian byte order and see the integer each order decodes to.

Width

Big-endian (network byte order)

12 34 56 78
Unsigned
305419896
Signed (32-bit)
305419896

Little-endian (x86 / ARM memory order)

78 56 34 12
Unsigned
2018915346
Signed (32-bit)
2018915346
Try an example:

Big-endian vs little-endian, byte by byte

Endianness is only about the order bytes are stored - it never changes the number itself. The 32-bit value 0x12345678 is three hundred and five million, four hundred nineteen thousand, eight hundred ninety-six no matter which machine holds it. What differs is the layout in memory:

OrderAddress 0123
Big-endian12345678
Little-endian78563412

Note that the digits within each byte never move: 12 stays 12. Reversing hex digits instead of bytes (getting 87654321) is the single most common mistake when swapping by hand.

When byte order bites

  • Hex dumps look backwards. On x86 the integer 1 appears in memory as 01 00 00 00. Read those bytes as big-endian and you get 16,777,216 instead of 1.
  • Network protocols are big-endian. TCP/IP header fields, and anything you build with htonl/ntohl, use network byte order regardless of the host CPU.
  • File formats disagree. PNG, JPEG and Java class files are big-endian; BMP, WAV and most Windows structures are little-endian.
  • Floats are affected too. An IEEE 754 pattern read with the wrong byte order decodes to a completely unrelated value - check it on the hex to float converter.
  • Single bytes are immune. One byte has no internal order, so ASCII text and byte arrays need no swapping.

Code Examples

value = 0x12345678

# Swap byte order at a fixed width
value.to_bytes(4, 'big')     # b'\x124Vx'
value.to_bytes(4, 'little')  # b'xV4\x12'

# Reinterpret bytes the other way round
int.from_bytes(value.to_bytes(4, 'big'), 'little')  # 2018915346

# Or swap in place
import struct
struct.unpack('<I', struct.pack('>I', value))[0]    # 2018915346

Frequently Asked Questions

What is the difference between big-endian and little-endian?

Endianness is the order bytes are stored in memory or sent on the wire. Big-endian puts the most significant byte first, so the 32-bit value 0x12345678 is stored as 12 34 56 78. Little-endian puts the least significant byte first, storing the same value as 78 56 34 12. The number itself is identical - only the byte order differs.

How do I convert big-endian to little-endian?

Reverse the order of the bytes, not the hex digits within each byte. 0x12345678 becomes 0x78563412. Paste the value above and the tool shows both orders plus the integer each one decodes to.

Which systems use which byte order?

x86, x86-64 and most ARM configurations are little-endian. Network protocols (TCP/IP), Java's serialization, and many file formats such as PNG and JPEG use big-endian, which is why big-endian is also called network byte order.

Why does my hex dump look reversed?

Memory dumps on a little-endian machine show the least significant byte first, so a 32-bit integer 1 appears as 01 00 00 00 rather than 00 00 00 01. Reading those bytes as big-endian gives 16777216 instead of 1 - a classic source of parsing bugs.

Does endianness apply to a single byte?

No. Endianness only describes the ordering of multiple bytes within a larger value. A single byte, and text encoded one byte per character, has no byte order to swap.

Related Tools

This tool runs entirely in your browser - nothing you enter is uploaded or stored.