Merkle trees explained: one seal at the top vouches for every line below
A Merkle tree hashes every transaction, then hashes the results in pairs, again and again, until one hash is left: the Merkle root in the block header. It lets anyone prove that one transaction is in a block with a dozen hashes instead of the whole block.
Grandma Rosa has paid the baker. She wants to know that the payment made it into the notebook. But her cottage is small, and every page of the notebook holds thousands of lines. She has no room for the whole book.
Anna shows her a trick. Every line on a page gets its own little wax seal. Then each pair of seals is pressed into one new seal. Then each pair of those. Up and up, until a single seal sits at the top of the page. To check her line, Rosa only needs her own seal, a handful of neighbouring seals, and the one at the top.
That's a Merkle tree. It turns "trust me, your payment is on the page" into "here are twelve seals, check them yourself".
What it is
A Merkle tree is a way to sum up a long list with one hash, so that anyone can later prove a single item is in the list without showing the rest. It's named after Ralph Merkle, whose US patent, filed in 1979 and granted on 5 January 1982, describes an "authentication tree" in which the computation of the root "forms a binary tree" (US patent 4,309,569).
In Bitcoin, the list is every transaction in a block, and the top hash is the Merkle root in the block header. The white paper puts it plainly: transactions "are hashed in a Merkle Tree", "with only the root included in the block's hash" (Bitcoin white paper, section 7).
How it works
The rules come from Bitcoin's developer reference. Take the transaction IDs in order, coinbase first. Join them in pairs, "concatenated together as 64 raw bytes", and hash each pair twice with SHA-256. Repeat on the new row until one hash is left. If a row has an odd number of hashes, "the last TXID is concatenated with a copy of itself and hashed" (developer reference).
Here is a real, tiny tree. Block 170, mined on 12 January 2009, holds two transactions (mempool.space):
- The coinbase, ID b1fea524...1c5082.
- A payment of 10 bitcoin, ID f4184fc5...1e9e16.
Join the two IDs (in the byte order the rules require) and hash the 64 bytes twice with SHA-256. Anyone can repeat it with Python's standard hashlib library. The result is 7dac2c5666815c17a3b36427de37bb9d2e2c5ccec3f8633eb91a4205cb4c10ff. That is, character for character, the Merkle root stored in the header of block 170 (mempool.space). Two lines, one seal.
Now the useful part: a big page. Each level of the tree halves the number of hashes. A block with 4,000 transactions needs 12 levels, because 2 to the power of 12 is 4,096. To prove that one transaction is in it, you need only the 12 neighbouring hashes on the way up, one per level. At 32 bytes each, that's 384 bytes. Rosa hashes her line with the first neighbour, the result with the second, and so on. If she lands on the Merkle root in the header, her line is on the page. If anyone changed a single line, she wouldn't.
Double the block to 8,000 transactions and the proof grows by one hash, to 13. That's the magic of halving: the page can grow a lot while the proof barely notices.
Why it matters
- Light wallets. The white paper's section 8 describes "Simplified Payment Verification": a user "only needs to keep a copy of the block headers" and gets "the Merkle branch linking the transaction to the block" (Bitcoin white paper). That's how a phone wallet can check a payment without storing the whole chain.
- Small headers. The white paper estimates a header at about 80 bytes and, at one block every ten minutes, about 4.2MB of headers a year. The Merkle root is what lets 80 bytes stand for a block of thousands of payments.
- Tamper evidence. Change one transaction and its hash changes, then its parent's, then every hash up to the root. The header no longer matches, and every house in the village sees it.
- Beyond Bitcoin. Taproot uses a Merkle tree of spending scripts, so a coin reveals only the branch it uses. More on that in our article on Schnorr signatures and Taproot.
Where people get it wrong
- "The Merkle root encrypts the transactions." No. Every transaction is public on the page. The tree only proves which ones are there.
- "A Merkle proof shows the payment is valid." It shows the payment is in a block. Section 8 is honest about the limit: a light client "can't check the transaction for himself". It trusts that the miners and nodes who accepted the block checked the rules.
- "Bigger blocks need bigger proofs." Barely. Doubling the transactions adds one hash to the proof.
- "The tree is stored in the block." Only the root is in the header. The rest can be rebuilt from the transactions at any time.
Check the seal yourself
Open any block on a block explorer and find the field called Merkle root. Then look at the transaction count. Work out how many times you'd halve that number to reach one. That's how many hashes it would take to prove any single payment on that page.
Then remember the stranger at the gate who says his app "verifies everything on the blockchain" for a monthly fee. Your phone does the maths for twelve seals for free. Ralph Merkle filed the idea in 1979.
Frequently asked questions
What is a Merkle tree in simple terms?
It's a way to sum up a long list with one hash. Each item is hashed, then the hashes are combined in pairs and hashed again, until one hash is left at the top. Change any item and the top hash changes.
What is the Merkle root in a Bitcoin block?
It's the single hash at the top of the Merkle tree of all transactions in the block. It sits in the 80-byte block header, so the block's own hash covers every transaction. If any transaction changed, the Merkle root and the block hash would change too.
How big is a Merkle proof?
One hash per level of the tree. A block with 4,000 transactions has 12 levels, so the proof is 12 hashes of 32 bytes, or 384 bytes. Doubling the number of transactions adds only one more hash.
What is Simplified Payment Verification?
It's the method from section 8 of the Bitcoin white paper. A light wallet keeps only block headers and asks for the Merkle branch linking its transaction to a block. It can see the payment was included, but it relies on full nodes to have checked the rules.
Who invented Merkle trees?
Ralph Merkle. His US patent, filed on 5 September 1979 and granted on 5 January 1982, describes an authentication tree built with a one-way function. Bitcoin uses the same idea with double SHA-256.
Sources
- Satoshi Nakamoto, Bitcoin: A peer-to-peer electronic cash system (2008), sections 7 and 8
- Ralph C. Merkle, US patent 4,309,569, Method of providing digital signatures (granted 5 January 1982)
- Bitcoin developer reference, Block chain (Merkle trees)
- mempool.space API, Bitcoin block 170 (12 January 2009)
- mempool.space API, transaction IDs in block 170

