blockchains · Git · BitTorrent · CT logs

Merkle tree hash demo

Merkle trees combine leaf hashes into a single root hash. Each line of input becomes a leaf. Every pair of hashes is concatenated and re-hashed up the tree. Used in Bitcoin blocks, Git commits, and BitTorrent.

0 leaves
Merkle root (SHA-256)
 

How to use this tool

  1. Type or paste your data blocks into the Leaves (one per line) box — each non-empty line becomes one leaf.
  2. The Merkle root (SHA-256) field fills in instantly with the full root hash.
  3. The tree below shows each level: the leaves row and how pairs of hashes combine upward.
  4. Watch how an unpaired hash on an odd level is carried up and marked with a *.
  5. Use Clear to wipe the input and start over.

Why this tool is helpful

See how Bitcoin blocks work

Each block header commits to all its transactions with a single Merkle root. This demo runs the same hierarchical hashing live.

Understand Git's object model

Git hashes commits, trees, and blobs into a Merkle-like structure. Hashing leaves upward mirrors how content addressing works.

Learn Merkle proofs

To prove one leaf belongs to a root you only need O(log n) sibling hashes — the key to lightweight, trustless verification.

Verify data integrity

Change any single leaf and the root hash changes completely, making any tampering immediately obvious.

Grasp content-addressed systems

BitTorrent and certificate-transparency (CT) logs rely on Merkle trees for efficient, verifiable bulk data.

Stay private

Everything runs in your browser. Nothing is uploaded, logged, or sent to a server — safe for sensitive inputs.

FAQ

What is a Merkle tree?

A tree where the leaves are hashes of your data and each parent is the hash of its children's concatenated hashes, collapsing into a single root hash.

Which hash algorithm does this demo use?

SHA-256, via the browser's Web Crypto API (crypto.subtle.digest). The final root is shown as a 64-character hex digest.

Why does my tree show an asterisk (*) on some rows?

When a level has an odd number of hashes, the last unpaired hash is carried up to the next level unchanged and marked with a *, instead of being concatenated with a partner.

Why did the root change when I edited only one line?

Every leaf feeds into the root. Changing a single leaf changes that leaf's hash, which cascades upward and produces a completely different root.

What happens to empty lines?

Empty and whitespace-only lines are ignored, so they do not become leaves and do not affect the root.

How is my text turned into a hash?

Each line is encoded as UTF-8 and hashed with SHA-256 to form a leaf. Pairs of hashes are then concatenated and re-hashed to produce each parent, up to the root.

Does any of my data leave my browser?

Never. All hashing happens locally in JavaScript. Your input is not sent to, stored on, or logged by any server.