TECHNICAL_DOC // GENERAL / LITTLE-ENDIAN
LITTLE
ENDIAN
ENDIAN
Little-endian means the least significant byte (LSB) is stored first at the
lowest memory address. Bitcoin's wire protocol stores all integer fields — version, value,
locktime, nonce — in little-endian format, matching the native byte order of x86/x64
processors. The most counter-intuitive consequence: TxIDs and block hashes appear
byte-reversed when compared between raw data and block explorers.
LITTLE_ENDIAN_IN_PRACTICE
READING A transaction/">RAW TRANSACTION FIELD
Raw tx hex (first 4 bytes = version):
02 00 00 00
Bytes in memory order: 02 00 00 00
↑ LSB MSB ↑
Read as little-endian uint32:
= 0x00000002 = 2 (decimal)
→ version 2 transaction ✓
Without knowing it's LE:
0x02000000 = 33,554,432 ← wrong
Satoshi value (8 bytes LE), e.g. 1 BTC = 100,000,000 sat:
Raw: 00 e1 f5 05 00 00 00 00
Read: 0x0000000005f5e100 = 100,000,000 ✓
TxID Reversal — The Classic Confusion
HASH BYTE ORDER
Bitcoin hashes are stored internally as little-endian 256-bit integers but displayed to humans in reversed (big-endian) byte order on block explorers.
TxID as it appears in a raw transaction (LE):
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
Same TxID as shown on a block explorer (bytes reversed):
55b852b7... → reversed → e3b0c442...
Reversing 32 bytes:
Step 1: split into 32 pairs (bytes)
Step 2: reverse the order of the pairs
Not reversing nibbles within each byte
Example (4 bytes for clarity):
Wire (LE): 78 56 34 12
Display (BE): 12 34 56 78
Bitcoin Core's RPC returns txids in display order (big-endian). When decoding raw transactions by hand, always reverse 32-byte hashes before comparing to explorer output.
TERMINOLOGY_INDEX
Little-Endian
Byte order where the least significant byte comes first. Used for all integers in Bitcoin's wire format.
LSB
Least Significant Byte. The byte with the smallest place value. Stored first in little-endian.
MSB
Most Significant Byte. The byte with the largest place value. Stored last in little-endian.
Internal Byte Order
Bitcoin's on-wire and on-disk format — little-endian for integers, little-endian for hash comparisons.
INTERACTIVE — TRY IT YOURSELF
INTERACTIVE_DOC // GENERAL / LITTLE-ENDIAN
LITTLE ENDIAN
INTERACTIVE
INTERACTIVE
Endianness trips up every Bitcoin programmer at least once. The protocol stores
multi-byte integers least-significant-byte first, so version
2 is on the wire as 02 00 00 00. The bigger trap: TXIDs and
block hashes are flipped between their internal storage form and the form block
explorers show you. This page lets you see the byte reversal happen — type a
number, watch the bytes; paste a TXID, watch it flip.
§ 1 — NUMBERS BECOME BYTES (BE vs LE SIDE-BY-SIDE)
Type any non-negative integer. The page shows it stored as uint8 / uint16 / uint32 /
uint64 in both orderings. The orange-bordered byte is the MSB, the
green-bordered byte is the LSB. Bitcoin's wire format always puts the green
byte first.
INTERACTIVE — INTEGER → BYTES (BE & LE)type a number
Why does Bitcoin use little-endian? Inheritance. Satoshi targeted x86,
where LE is the native CPU byte order. Reading a struct field directly from a memory
buffer is essentially free in LE. The cost is paid by humans — who naturally write
numbers MSB-first — every time we eyeball raw transaction bytes.
§ 2 — TXID REVERSAL (THE CLASSIC TRAP)
Block hashes and TXIDs are stored internally as little-endian 256-bit integers, but
every block explorer in existence displays them in big-endian (display) order
— i.e. byte-reversed. Same 32 bytes, two presentations. Get this wrong and your
"TXID lookup" silently returns nothing. Click Reverse below to flip.
INTERACTIVE — 32-BYTE HASH FLIPPERclick reverse
CURRENT BYTE ORDER
YOU NOW HAVE
— click reverse —
Memorable example: The genesis block hash is shown as
000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
on every explorer. Its raw little-endian form (what's actually stored in memory and on
disk) is the same bytes reversed. The leading zeros — proof of work — appear at
the end of the LE form, not the start.
§ 3 — ENDIANNESS BATTLE (WATCH THE NUMBERS DIVERGE)
Same bytes, two readings. Type any 4-byte hex value below to see how dramatically
interpretation changes when you guess wrong. This is the bug everyone ships at least
once: parsing version
2 as 33,554,432 because they read it
big-endian instead of little.
INTERACTIVE — SAME BYTES, TWO READINGSpaste 4 bytes
★ LITTLE-ENDIAN (Bitcoin)
—
—
BIG-ENDIAN (wrong here)
—
—
§ 4 — REAL TRANSACTION FIELD DECODER
Click each tab to load a real raw-transaction field. The page parses it correctly
(LE for integers) and shows you what the value means. This is the byte-by-byte
workflow you'll use whenever Bitcoin Core's debug output drops a hex blob in your lap.
INTERACTIVE — DECODE REAL TX FIELDSswitch tabs
TERMINOLOGY_INDEX
Little-Endian
Byte order placing the least-significant byte first. Native to x86/x64. Used for all Bitcoin integer fields on the wire.
Big-Endian
Byte order placing the most-significant byte first. "Network byte order" in many protocols (TCP, IP). Display order for Bitcoin hashes.
LSB
Least Significant Byte. The byte representing the smallest place value. First in little-endian.
MSB
Most Significant Byte. The byte representing the largest place value. Last in little-endian, first in big-endian.
Internal Order
Bitcoin's on-wire/on-disk byte order — little-endian for integers and hashes alike.
Display Order
Reversed (big-endian) form of a hash for human reading. What block explorers and RPC return.
Reverse Hex
To convert internal ↔ display: split into 2-char byte chunks, reverse the order of chunks. Don't reverse nibbles within a byte.