Build merkle tree

Build a Keccak-256 Merkle root and inclusion proof from ordered text leaves.

freeworks offlinenothing uploaded
ToolMerkle Tree Builder
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

Each UTF-8 leaf is Keccak-256-hashed, adjacent hashes are concatenated left-to-right, and an odd final node is paired with itself. The selected leaf records each sibling hash and side while the final level supplies the root.

  • The first value is selected when no proof index is supplied.
  • Duplicating an odd node keeps every level pairable without a sentinel hash.

Worked example

Four values, proof for the second
A balanced tree, so no duplication is needed
Input
											Values: ["alice","bob","carol","dave"]
Leaf index: 1
										
Output
												Merkle root hex: 415e49eafecf2263e29c49dcf6473e52dbf4b0f03090ff949b52aabc88aa1e8b
Leaf hash hex: 38e47a7b719dce63662aeaf43440326f551b8a7ee198cee35cb5d517f2d296a2
Tree depth: 2
Leaf count: 4
Proof sibling hashes: 9c0257114eb9399a2985f8e75dad7600c5d89fe3824ffa99ec1c3eb8bf3b0501, b81613f04cd9ce07b4781be9bbaa86a503220985be2a3f168b30d158da0db0e2
Proof sibling positions: left, right
											

When to use this

Airdrop contracts verify user proofs, rollups publish state roots, and content manifests commit many records to one digest.

Edge cases

  • An odd number of leaves duplicates the last hash at that level; dropping it changes the root.
  • The visible text é is UTF-8 encoded, so a legacy single-byte client will produce another leaf.
  • Reordering the same values changes parent hashes even though the set is unchanged.

References