1. Home
  2. Developer tools
  3. Endian Converter

Endian Converter

Network protocols use big-endian order while most CPUs store integers little-endian. Enter a hex value, choose its width, and see the swapped value and the exact bytes at each memory offset in both orders.

Free, no sign-up. Runs in your browser: nothing is uploaded.

How to use Endian Converter

  1. Enter a hex value or a decimal number.
  2. Choose the width in bytes.
  3. Read the swapped value and the memory layout.

Features

  • Byte swap for 2, 4 and 8 byte values
  • Original and reversed bytes side by side
  • Decimal values of both readings
  • Accepts 0x prefixes and spaces between bytes
  • Any byte count, or fixed 16, 32 and 64-bit widths
  • The reversed bytes as one hex number

Supported formats

Input

  • Hex bytes
  • Decimal number

You get

  • Swapped hex
  • Decimal readings

Private by design

Everything you enter is processed by your browser on this device. Nothing is sent to openWorkstand or anyone else, so the Endian Converter is safe for private and work data. After you have used it once while online, it also works without an internet connection. How local processing works

Good to know

  • Only whole bytes are swapped, so an odd number of hex digits is padded with a leading zero.
  • It reorders bytes; it does not know what the value means, so mixed-size structures must be swapped field by field.

Guide

Endianness: reading multi-byte numbers in the right order

A byte holds 0 to 255 whatever machine you use, but a number that needs several bytes must be laid out in some order, and there are two sensible choices. Big-endian puts the most significant byte first, the way we write decimal numbers. Little-endian puts the least significant byte first. Neither is more correct, and both are in daily use, so data that crosses from one world to the other often needs its bytes turned round.

The two orders

Take the 32-bit number 0x12345678. A big-endian machine stores the bytes at increasing addresses as 12 34 56 78. A little-endian machine stores 78 56 34 12. The same four bytes mean different numbers depending on the order in which you read them: 305,419,896 in one case and 2,018,915,346 in the other. The converter prints both readings, so a value that looks absurd in one order can be checked against the other.

Who uses which

Internet protocols use big-endian and call it network byte order, so port numbers and addresses in packet headers are in that order. File formats such as PNG and Java class files are also big-endian. The x86 and x86-64 processors are little-endian, and so are most ARM systems in their usual configuration, which means that programs on those machines must convert before sending numbers over a network or writing them to a big-endian format. Some formats, such as TIFF, announce their order in the header.

Using the page

Type the bytes as hexadecimal, with or without spaces and a 0x prefix, and choose a width: 16, 32 or 64 bits, or “any number of bytes”. The page shows the original bytes, the reversed bytes, the reversed bytes as one hex number, and the decimal reading in each order. Below that a table lists the offsets +0, +1, +2 and so on with the byte stored there for big-endian and little-endian layouts.

Edge cases

If you enter an odd number of hex digits, a zero is added at the front so that the bytes are whole. When a fixed width is chosen, the value must have exactly that many bytes, and the page reports the mismatch otherwise, so write any leading zero bytes yourself. Swapping a value twice returns the original. A single byte is its own reverse. The tool swaps the whole value; structures with several fields of different sizes must be swapped field by field, since reversing the entire block would also reverse the order of the fields.

A worked example

The Sample button loads 12 34 56 78. The reversed bytes are 78 56 34 12, which is 0x78563412 when written as one number. Read as big-endian the original is 305,419,896, and read as little-endian it is 2,018,915,346. In the memory table, a big-endian machine would hold 12 at offset +0 and 78 at offset +3, and a little-endian machine would hold 78 at +0 and 12 at +3. If your code printed 0x78563412 where you expected 0x12345678, you have found a missing conversion.

Limits

The page cannot tell which order your data is in; you have to know the specification of the format or the machine. It treats the input as unsigned bytes and does not interpret floating-point numbers, so for a float or double use the IEEE 754 converter after correcting the order. It only reverses whole bytes and never reorders bits.

Checked against the current version of the Endian Converter on .

Frequently asked questions

How can I tell that a number in a hex dump has the wrong byte order?

Compare it with what you expect. A small number such as 1 stored in four bytes looks like 01 00 00 00 in little-endian and 00 00 00 01 in big-endian. If a length field reads 16 million instead of a few hundred, the bytes are almost certainly reversed.

Does endianness change the order of the bits inside a byte?

No. It only concerns the order of whole bytes. Within a byte the value is the same on every machine, although some serial protocols send the bits of a byte least significant first, which is a separate matter.

What is 0x12345678 in little-endian?

The bytes in memory are 78 56 34 12. Read back as a number the swapped value is 0x78563412.

Which order do network packets use?

Big-endian, also called network byte order, in the Internet protocols. Intel and ARM in their usual modes store integers little-endian, so values are swapped when sent.

Keep working with the result

openWorkstand also includes a free workspace with documents, spreadsheets, tasks, projects and a calendar that save to a folder on your computer.