Block hash
A bitcoin block hash is the double SHA-256 of an 80-byte block header. It names the block and must fall below the target. Learn how to compute it.
By Dimitar Zurnov · Updated 4 Nov 2026
Adapted from Learn Me a Bitcoin by Greg Walker.
A block hash is the identifier of a block. You get it by running the 80-byte block header through SHA-256 twice. The header holds the merkle root and the previous block hash, so the block hash depends on every transaction in the block and on the whole chain before it. Bitcoin Core's block header class has the same six fields. Change any byte of the header, and the hash changes.
How is a block hash made?
The steps are short:
- Take the 80 bytes of the block header.
- Run them through SHA-256.
- Run that 32-byte result through SHA-256 again. Bitcoin calls the double hash HASH256, which is the hash function applied twice.
The hash of the genesis block shows the steps. This Python code takes the genesis header as raw bytes and hashes it:
import hashlib
# The 80-byte genesis block header, as raw bytes.
header = bytes.fromhex(
"0100000000000000000000000000000000000000000000000000000000000000"
"000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa"
"4b1e5e4a29ab5f49ffff001d1dac2b7c")
block_hash = hashlib.sha256(hashlib.sha256(header).digest()).digest()
print(block_hash.hex()) # 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000
print(block_hash[::-1].hex()) # 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
print(int(block_hash[::-1].hex(), 16))
The first line is the hash in natural byte order, which is the order it leaves the hash function. The second line reverses those bytes, and that is the form explorers show. The block 0 page in our explorer shows the second form.
Do not hash the header as a hex string. Convert the hex to raw bytes first, because the hash function works on bytes.
Why do block hashes start with zeros?
A block is valid only if its hash, read as a number, is below the target. The target has many leading zeros, so a valid hash must have them too.
The genesis hash starts with 10 zero hex digits, and it sits below the genesis target. Block 974,000's target has 19 leading zero digits. Its hash starts with 20, so it is below that target. A hash with only 18 leading zeros would be above the target, so no miner could use it.
Miners cannot choose the hash. They change the nonce and other header fields, and each try is a lottery ticket. The nonce page shows how the search works.
What is the block hash used for?
Block hashes do two jobs:
- Searching. Paste a block hash into an explorer to find that block, as in block 974,000 on our site. Explorers show it in explorer order, not natural order.
- Linking. The next block stores this hash in its previous block field. Those links are what make the chain.
Is a block hash a number or a set of bytes?
Both. A hash is 32 bytes, and those bytes carry no meaning on their own. But they are unique for each header, so they work as an identifier.
Miners also read the hash as a number, and compare it with the target. The genesis hash, read as a decimal number, is 10628944869218562084050143519444549580389464591454674019345556079. That number is far below the genesis target.
Why does the byte order look reversed?
The hash function outputs bytes in one order, which Bitcoin calls natural byte order. Explorers show the same bytes in the reverse order, so that the leading zeros appear first. The result is the same hash, written two ways. The byte order page explains both orders.
If you copy a hash from one tool into another and the search finds nothing, check the order first. A hash pasted in the wrong order will usually match no block at all.
What comes next?
Next is blk.dat files, which shows where your node keeps the raw blocks.
In this section: Block structure
Something look wrong? Tell us