Hex converter with byte order

Convert hexadecimal, decimal and binary values, paste a list of bytes such as 78 56 34 12 or €, and see the same value in big-endian and little-endian byte order with its unsigned and signed readings. Nothing you type leaves your browser.

Input is
Read it as
Byte order
Try:

How to use

  1. Type a value in Value and say how it is written in Input is: hex (an optional 0x or # prefix is accepted), decimal, or binary. Negative decimal numbers such as -2 are allowed.
  2. Choose Read it as. One number treats spaces and underscores as digit separators. Byte list treats each space-separated group as one byte, so DE AD BE EF is four bytes. Auto reads a list of groups as bytes only when every group is exactly two hex digits (or eight bits), or when the text contains \x escapes; the tool says which rule it applied.
  3. Choose the Byte order. It decides the order the bytes are shown in, and how a byte list is combined into a number: big-endian puts the first byte in the most significant position, little-endian puts it in the least significant position.
  4. Pick a Width, or leave "Smallest that fits". A number that does not fit the chosen width is rejected with the largest value that does. A negative number is shown as its two's complement pattern in that width (invert the bits of the magnitude and add 1; the two's complement page shows the steps).
  5. Read the results: unsigned and signed values for the same bits, bytes in both orders, grouped binary, a nibble table (each hex digit with its four bits and its weight) and copyable forms such as 0xDEADBEEF, \xDE\xAD\xBE\xEF and a C array.

Worked examples

Each value is recomputed by an automated test from the same engine as the tool; the arithmetic below is also checked on its own in the tests.

One hex number, four bytes, two readings

DEADBEEF has eight hex digits, and each hex digit is exactly four bits, so it is 32 bits or four bytes. As an unsigned number it is 13 x 167 + ... = 3735928559. Its top bit is 1, so read as a signed 32-bit integer it is 3735928559 - 232 = -559038737.

Input is hex, read as one number, width: smallest that fits

Input: 0xDEADBEEF

Output: big-endian DE AD BE EF; little-endian EF BE AD DE; unsigned 3735928559; signed -559038737

The same four bytes, two byte orders

If memory holds the bytes 78 56 34 12 in that order, a little-endian reader treats the first byte as the least significant: the number is 0x12345678, which is 1 x 167 + 2 x 166 + ... = 305419896. A big-endian reader treats the first byte as the most significant: 0x78563412 = 2018915346.

Input is hex, byte list, little-endian

Input: 78 56 34 12

Output: bytes 78 56 34 12; read little-endian = 305419896

Input is hex, byte list, big-endian

Input: 78 56 34 12

Output: bytes 78 56 34 12; read big-endian = 2018915346

Escapes from a log or a string literal

Each \xNN is one byte. The three bytes E2 82 AC are the UTF-8 encoding of the euro sign (the ASCII and UTF-8 page shows why), and as a single big-endian number they are 0xE282AC = 14844588.

Input is hex, auto

Input: \xE2\x82\xAC

Output: bytes E2 82 AC; read big-endian = 14844588

Decimal in, bytes out

255 is the largest value one unsigned byte holds. The same eight 1-bits read as a signed byte are -1.

Input is decimal

Input: 255

Output: big-endian FF; little-endian FF; unsigned 255; signed -1

A negative decimal becomes its two's complement bytes: -2 is 256 - 2 = 254 = FE.

Input is decimal

Input: -2

Output: big-endian FE; little-endian FE; unsigned 254; signed -2

What goes wrong

Real inputs that surprise people. Each result is the tool's exact output and is covered by a test.

#fff is a colour in CSS, a number here

CSS reads #fff as the colour #ffffff, because a 3-digit hex colour repeats each digit. As a number, fff is 4095. The tool does not guess; it reads the number and adds a note that a colour would be read differently. The odd digit count also means one leading zero is added to make whole bytes, so the bytes are 0F FF.

Input is hex

Input: #fff

Output: big-endian 0F FF; little-endian FF 0F; unsigned 4095; signed 4095

A letter that is not a hex digit

Input is hex

Input: 1G

Error: Character "G" at position 2 is not a valid hexadecimal digit.

A "byte" with seven digits

When you choose "Byte list", each group is one byte, so at most two hex digits. If the text is really one long number, choose "One number".

Input is hex, byte list

Input: DEADBEE

Error: Byte 1 ("DEADBEE") has 7 digits; a byte needs at most 2 in hex.

-129 does not fit in one byte

One signed byte holds -128 to 127. -129 needs two bytes: 65536 - 129 = 65407 = FF7F. In the smallest-width setting the tool widens by itself; with a fixed width of 1 byte it would refuse and say so.

Input is decimal

Input: -129

Output: big-endian FF 7F; little-endian 7F FF; unsigned 65407; signed -129

A different reading of the same text in JavaScript

parseInt("0xFFFFFFFF") gives 4294967295, and (0xFFFFFFFF).toString(16) gives ffffffff, but (-1).toString(16) gives -1, not ffffffff: JavaScript prints a sign and the magnitude and does not show two's complement bits. To see the bits of a negative number, use (n >>> 0).toString(16), or paste the number here.

Limits & gotchas

  • Size. At most 4000 characters of input and 1024 bytes in a byte list. Numbers are exact arbitrary-size integers; there is no 253 limit.
  • Integers only. There is no hex fraction (0x1.8p3) support here. For fractional values in other bases, use the base converter; for hex floating-point bit patterns use the IEEE 754 page.
  • Byte order is only a display and combination choice. The tool cannot know the order your file format or CPU uses; it shows both so you can compare with what you see.
  • A minus sign makes the value negative, whatever the input base. -0xFF is -255 and is shown as the two's complement bytes FF 01 in two bytes. Without a minus sign, hex and binary digits are taken as the unsigned bit pattern as typed.
  • Nibble table. Shown for values of up to 8 bytes; the byte boxes and grouped binary cover longer values.
  • Browser. Tested in a current Chrome only.

FAQ

Why do the bytes come out reversed from the hex number I typed?

Because you are looking at little-endian memory order. The number 0x12345678 is written most significant digit first, so as bytes it is 12 34 56 78. A little-endian machine (x86 and most ARM implementations, per Wikipedia: Endianness) stores the least significant byte at the lowest address, so memory holds 78 56 34 12. The tool shows both orders for the same number. Network protocols in the Internet protocol suite use big-endian ("network order"), but not every protocol does: SMB is little-endian.

What is the difference between 78 56 34 12 as a number and as bytes?

As a list of bytes it is four values. As one number it depends on the byte order you read it with: little-endian gives 0x12345678 = 305419896, big-endian gives 0x78563412 = 2018915346. Both appear on this page under Worked examples. The "Read it as" setting decides whether spaces separate bytes or are ignored inside a single number; Auto picks "bytes" only when every group is exactly two hex digits (or eight bits in binary).

Why is 0xFFFFFFFF sometimes -1 and sometimes 4294967295?

The same 32 bits mean 4294967295 if the type is unsigned and -1 if it is a signed two's complement integer. The bits do not say which. In JavaScript, 0xFFFFFFFF is the Number 4294967295, but 0xFFFFFFFF | 0 is -1 because the bitwise operators convert to a signed 32-bit integer first. The tool prints both readings of the bits and tells you when they differ.

Is #fff the same as 0xfff?

No. In CSS a 3-digit hex colour duplicates each digit, so #fff is #ffffff (CSS Color Level 4). As a plain number, fff is 0xfff = 4095. The tool treats the # as just a prefix, reads the number, and adds a note that a colour would be read differently. If you mean a colour, type all six digits.

How do I get the UTF-8 bytes of a character in hex?

Use the ASCII and UTF-8 converter, which starts from text and shows each character's code point, bit layout and bytes. The hex converter here goes the other way round for escapes: paste \xE2\x82\xAC and it reads three bytes, E2 82 AC, which are the UTF-8 bytes of the euro sign. Each \xNN escape is exactly one byte, however it is displayed.

Sources

  • Wikipedia: Endianness Used for: Definitions of big-endian and little-endian; network order is big-endian for the Internet protocol suite; x86 and most ARM implementations are little-endian; not every protocol uses big-endian (SMB is little-endian).
  • Wikipedia: Two's complement Used for: The most significant bit is the sign; one zero and one extra negative number (a 4-bit range of -8 to +7); invert-and-add-one; sign extension repeats the most significant bit; the most negative number has no positive counterpart.
  • Wikipedia: Positional notation Used for: A number is written as digits multiplied by powers of the base, with the radix point separating the integer and fractional parts.
  • W3C: CSS Color Module Level 4: RGB hex notations Used for: A 3-digit hex colour such as #fff duplicates each digit (#ffffff).
  • MDN Web Docs: parseInt() Used for: parseInt stops at the first character that is not a digit in the radix, returns NaN if the first character is not, and works on Numbers, not BigInt.
  • MDN Web Docs: DataView Used for: DataView reads and writes big-endian by default although most platforms are little-endian. Used in the unit tests as an independent oracle for float encoding.
  • MDN Web Docs: BigInt Used for: BigInt holds integers of arbitrary size; mixing BigInt and Number in arithmetic throws a TypeError.

Every document above was opened and read on 2026-10-02. Documentation changes; if a page here disagrees with the current docs, trust the docs and tell us.

A hex digit stands for exactly four bits because 16 = 24; the tests check every conversion against JavaScript's BigInt and Number.prototype.toString(16).