All Posts

Bitcoin Mining Difficulty & Target

Definition: The Bitcoin mining difficulty defines how hard it is to mine a new block. In average it takes ten minutes to mine a block.

A general explanation of the mining difficulty can be found here: There are two values we need to consider:

  1. the target (or bits): The target states how high a block hash can be in order to fulfill the mining condition. The higher the target the easier it is to find a value below it and the lower the difficulty.
  2. the difficulty: Is a numerical expression of how difficult it is to find a suitable hash compared to the easiest difficulty of 1. The difficulty value is easier to interpret for individuals. A difficulty of 6,152,656.45 means it takes 6,152,656.45 times more tries (in average) to find a suitable hash than with the easiest difficulty of 1. If the hash rate would remain constant this would lead to a 6,152,656.45 times longer block finding time.

You’ll find the formula for the calculation of the difficulty and target below.

What is the Bitcoin Target?

The Bitcoin difficulty target is a 256-bit number. It is stored as a packed hexadecimal value. The field where it is stored is called “bits”.

The target defines the max height of a block header to be a valid block. This means, the higher the target the lower is the difficulty. You can imagine that like a Limbo dance.

It gets adjusted according to the hash rate in order to maintain a constant block finding time and to dispense the block reward not too fast or too slow.

Where is the Difficulty Stored in Bitcoin Blocks?

In order to make the difficulty target forgery proof it is part of the block header and serves as input value of the SHA256 hash function during mining.

The difficulty target of each block is stored in a field called bits.

Typically, the target is stored in hexadecimal format. Some block explorers however give the target as a decimal number. It is possible to convert both values.

The following screenshots show both, difficulty and target in two blocks.

Difficulty & Target (Bits) Genesis Block

Difficulty and target of the Genesis block. (Source:

Difficulty and target of block 645964. (Source:

How is the Difficulty in Bitcoin Calculated?

The difficulty is adjusted every 2016 blocks. But since there is a bug in the implementation the adjustment happens every 2015 blocks. A fix would require a hard fork and therefore is not executed yet.

The reference implementation says that the average block finding time should be 10 minutes. So, after 2016 blocks 20160 minutes should have elapsed which are 14 days. (The whitepaper mentions only a moving average without concrete numbers.)

Now, the miners try to adjust the difficulty that way that the average block finding time of ten minutes remains.

Each block contains a timestamp and after 2016 blocks each miner calculates how much time has passed. If it is less than the expected time of 20160 minutes the difficulty was too low and needs to be raised. If it took longer the difficulty was too high and should be lowered.

The formula is:

new difficulty = current difficulty * expected time / actual time

  • new difficulty: difficulty for the next 2016 blocks
  • current difficulty: difficulty for the last 2016 blocks
  • actual time: time difference between first block of the difficulty period and 2016th block of this period
  • expected time: 20160 minutes (as stated in the whitepaper or protocol)

This calculator can also be found here.

Example 1

The following values are given:

  • current difficulty: 1
  • Time between the first and last block of each difficulty period: 15,000 minutes.

1.344 = 1 * 20,160 / 15,000

The new difficulty would be 1.344. It is higher than the previous value because it took less time to find the 2016 blocks than expected.

Example 2

The following values are given:

  • Current difficulty 625,413
  • Time between the first 25,000 and last block of the difficulty period

504335.4624= 625,413 * 20,160 / 25,000

Here, the difficulty goes down because it took more time than intended.

Example 3

This example is taken from the Bitcoin blockchain.

  • Timestamp block 98,784 (first block of the current difficulty period): 21.12.2010 19:34
  • Timestamp block 100,799 (last block of the current difficulty period): 2011-01-03 06:00
  • Current difficulty: 14,484.16

Time between block 98,784 and 100,799 = 17,906 minutes

16,307.42017 = 14,484.16 * 20,160 / 17,906

How is the Target in Bitcoin Calculated?

The target is calculated by this formula:

target = max_target / difficulty

  • max_target: the target, if difficulty is 1 (lowest possible difficulty). Its value is 1d00ffff.
  • difficulty: see above

To get the target from the bits another formula is used. The bits value consists of two parts, index and coefficient. The first byte is the index the following three bytes are the coefficient.

target = coefficient * 2 ^ (8 * (index – 3))

You can try out our target calculator to convert the “bit” value to target.

Bit as hexadecimal number:
Target as hexadecimal with padding:
Target as hexadecimal:
Target as decimal number:
Difficulty as decimal number:

Example 1

We take the values from Bitcoin block 646,083.

  • Given bits in decimal: 388618029

Now we convert it into hexadecimal and extract the index and coefficient.

  • bit in hexadecimal: 0x171007EA
  • coefficient: 0x1007EA
  • index: 0x17

target = 0x1007EA * 2^(0x8*(0x17 – 0x3)) = 0x1007EA0000000000000000000000000000000000000000

The 0x means it is a hexadecimal number

target in decimal: 1535456543183121267670627692621392373016562041515671552

So, the new hash needs to be lower than this value.

Example 2

Let’s calculate the highest possible target (the lowest difficulty)

Given bit in hexadecimal: 0x1d00ffff

Coefficient: 0x00ffff

Index: 0x1d

target = 0x00000000ffff0000000000000000000000000000000000000000000000000000

Connection Between Mining Difficulty and Hashrate

The higher the hash rate the higher will be the difficulty (or the lower the target). The Bitcoin hash rate can vary. New nodes joining the network or technical improvements increase it. But sometimes nodes are shut down if they are not profitable or legally banned. In this case the hash rate drops and the difficulty get reduced accordingly.

Further Links

Good technical explanations can be found here: