Little-endian
Little-endian in Bitcoin stores the least significant byte first. Most numbers in raw transactions and block headers use it. Learn to read them.
By Dimitar Zurnov · Updated 4 Nov 2026
Adapted from Learn Me a Bitcoin by Greg Walker.
Little-endian stores a number's bytes starting from the least significant one. Bitcoin uses it for almost every number in raw transactions and block headers, including output amounts, version numbers and timestamps. To read one of these fields, reverse its bytes, then read the result as an ordinary hex number.
What does little-endian look like?
Take 12,345,678 satoshis in an 8-byte amount field. As a hex number it is 0xBC614E. Padded to eight bytes, the big-endian form starts with the most significant byte, and the little-endian form starts with the least significant one. The bytes are the same in both. Only their order differs.
Only three of the eight bytes carry data here, and the other five are zero. The field could hold a number up to 0xFFFFFFFFFFFFFFFF, which is 18,446,744,073,709,551,615. Valid amounts are far smaller, because the total supply is 21 million BTC, or 2,100,000,000,000,000 satoshis.
How is it laid out in memory?
Memory holds one byte at each address. Big-endian stores the most significant byte at the lowest address, so the number reads left to right, as people write it. Little-endian does the opposite. It stores the least significant byte at the lowest address, so the number starts with its smallest part.
Bitcoin stores these fields that way, so they look backwards when you read the hex.
Why is it called little-endian?
The names come from Jonathan Swift's Gulliver's Travels (1726). In the story, two groups argue over whether to crack a boiled egg at the little end or the big end. Computer scientists borrowed the names for the two ways of ordering bytes. The Wikipedia article on endianness has the history and the hardware side.
Which fields use little-endian?
Almost every field that holds a number. The table shows real values decoded from raw data, using the fields as they appear in Bitcoin.
| Field | Size | Hex in the raw data | Value |
|---|---|---|---|
| Transaction version | 4 bytes | 02000000 |
2 |
| Input vout | 4 bytes | 01000000 |
1 |
| Input sequence | 4 bytes | fdffffff |
4,294,967,293 |
| Output amount | 8 bytes | 2a5f020000000000 |
155,434 sat |
| Block version | 4 bytes | 00000020 |
536,870,912 |
| Block time | 4 bytes | daf0d861 |
1,641,607,386 |
| Block bits | 4 bytes | ab980b17 |
386,635,947 |
| Block nonce | 4 bytes | 0e69d05c |
1,557,162,254 |
The numbers in the last four rows come from the header of block 717,664. Its time is a Unix timestamp. The stored bytes, daf0d861, read in big-endian order as 61d8f0da, which is 1,641,607,386. That moment is 8 January 2022, at 02:03:06 UTC.
Inside a transaction, the version, the vout, the sequence, the amount and the locktime are all little-endian.
Hashes are the exception. A hash is a string of bytes rather than a number, so it is never read as little-endian. Its display order is covered on the byte order page. Counts and lengths use compact size, which is little-endian only in its multi-byte forms.
How do you convert a little-endian number?
Reverse the bytes, then read the result as big-endian. Python can do both steps for you. The "little" argument tells to_bytes and from_bytes to use the little-endian order:
amount = 12345678
# eight bytes, least significant first
le = amount.to_bytes(8, "little")
# 4e61bc0000000000
print(le.hex())
# 12345678
print(int.from_bytes(le, "little"))
Python's struct module does the same with a format string. The < means little-endian, and the letter after it sets the size: H is 2 bytes, I is 4 bytes and Q is 8 bytes. So struct.pack("<Q", amount) gives the same eight bytes. Ruby's pack uses the same idea, with Q< for an 8-byte little-endian integer.
If you only have the hex text, reverse the byte pairs. For example, bytes.fromhex("daf0d861")[::-1].hex() gives 61d8f0da.
To find out whether your own machine is little-endian, run sys.byteorder in Python. Most computers print little.
Are there exceptions?
Yes, and the most useful one is in networking. Port numbers and IP addresses in network messages are big-endian. In a version message, the default mainnet port 8333 is written as 208d, with the high byte first. The rule is to check the field's definition, not to assume.
Where did little-endian come from?
The usual account is that Satoshi wrote the software on a little-endian machine. Most processors in use today also work that way. Many developers would have preferred big-endian, because it matches how people write numbers. Developers have argued about it since 2011.
Some developers point out that big-endian everywhere would match the reversed display of hashes. Others, including Pieter Wuille, a Bitcoin Core developer, have noted that CPUs work natively in little-endian. So the choice matters less than people think. Changing a field would break every transaction and block, so in practice the order is fixed.
Once you know the order, read the compact size page next. Its multi-byte values are little-endian too.
In this section: Data
Something look wrong? Tell us