Network Byte Order Converter for Binary – Free

This network byte order converter reverses the bytes of a binary value, so a little-endian word becomes big-endian network order and the other way around. The eight bits inside each byte keep their positions.

How to use the Binary Network byte order Converter tool

  1. Enter the value in the Binary digits box as whole bytes, for example 10111011 00000001.
  2. Select Convert. The tool reverses the sequence of bytes and leaves the bits inside every byte alone.
  3. Read the swapped value in the Result box, where each byte is printed as an 8-bit group.
  4. Select Copy to take the result. The Example button loads a single byte, which comes back unchanged because one byte has no order to swap.

What network byte order means

A number wider than one byte has to be stored or sent one byte at a time, and two conventions exist. Big-endian puts the most significant byte first. Little-endian puts the least significant byte first. Internet protocols chose big-endian: Appendix B of RFC 791 states that the most significant octet of a header field is transmitted first, and that convention is what people call network byte order.

Most desktop and phone processors are little-endian, so a port number or address in memory is often the reverse of what goes on the wire. C code fixes that with htons and htonl before sending and ntohs and ntohl after receiving. On a little-endian host those functions reverse the bytes. This tool performs the same reversal on the bits you type.

Worked example: port 443 and an IPv4 address

HTTPS uses port 443, which is 0x01BB. In a TCP header the two bytes travel as 00000001 10111011. A little-endian machine holds the same 16-bit integer in memory as 10111011 00000001. Paste the memory layout and the converter returns the wire layout.

A four-byte value works the same way. The address 192.168.1.1 is 11000000 10101000 00000001 00000001 in network order, and reversing it gives the layout a little-endian host would hold for that 32-bit integer.

10111011 00000001  ->  00000001 10111011
11000000 10101000 00000001 00000001  ->  00000001 00000001 10101000 11000000

Input rules for the byte swap

The converter works on complete bytes and treats everything you enter as one word.

  • The number of bits must be a multiple of eight. Otherwise the tool reports: Enter complete bytes, using eight bits per byte.
  • Spaces, tabs and line breaks between bits are ignored, so 0001001000110100 and 00010010 00110100 are the same input.
  • One 0b prefix at the very start is accepted and removed.
  • The limit is 65,536 bits, which is 8,192 bytes.
  • The output always separates bytes with single spaces, whatever spacing the input used.

One word at a time, and always a swap

Because the whole input is reversed as a single unit, pasting two 16-bit fields together swaps the fields with each other as well as the bytes inside them. Convert each header field separately, with exactly 2 bytes for a 16-bit field and 4 bytes for a 32-bit field.

The tool also cannot know which order your input is in. It reverses every time, so running it twice returns the original bytes. The Binary Endianness Converter on this site applies the identical reversal. The Bit reversal Calculator is different: it mirrors every bit, including the bits inside each byte.

Frequently asked questions

Is network byte order big-endian or little-endian?

Network byte order is big-endian. The most significant byte of a multi-byte field is sent first. IPv4, IPv6, TCP and UDP headers all use it for ports, lengths, sequence numbers and addresses.

Does this tool do the same thing as htons and htonl?

It does what those functions do on a little-endian host: reverse 2 bytes for htons or 4 bytes for htonl. On a big-endian host the C functions leave the value alone, while this tool reverses the bytes every time you select Convert.

Why did my input come back unchanged?

A single byte has only one possible order, so 01001101 returns 01001101. The same happens with any byte palindrome, such as 11111111 00000000 11111111. Enter at least two different bytes to see the order change.

Can I swap several 16-bit or 32-bit words in one go?

No. The tool reverses the entire input as one word, so the words would also trade places. Convert one field per run and assemble the results yourself.

Does byte order affect the bits inside a byte?

No. Endianness only describes the order of whole bytes. Each byte in the result contains exactly the same eight bits, in the same order, as it did in the input.

Related tools