TeachMeBitcoin

The Role of blk.dat Files

From TeachMeBitcoin, the free encyclopedia Reading time: 2 min

The Role of blk.dat Files

When you run a Bitcoin full node, the blockchain is stored on your hard drive in a series of files named blk00000.dat, blk00001.dat, and so on. These files are the "ground truth" of the Bitcoin network.

1. What are blk.dat files?

The blk.dat files are flat binary files that contain raw block data. Instead of using a traditional relational database (like SQL) to store blocks, Bitcoin Core simply appends new blocks to the end of the current .dat file.

2. The 128MB Limit

To prevent files from becoming too large and unwieldy for the operating system to handle, Bitcoin Core caps each blk.dat file at 128 MiB.

3. Raw Serialization

The data in these files is stored in its raw serialized format. This is the exact same byte-sequence that is transmitted over the P2P network.

4. Location on Disk

By default, these files are located in the blocks/ subdirectory of your Bitcoin data directory:

Property Value
File Format Binary (Raw)
Max Size 128 MiB per file
Content Serialized Blocks
Dependency Requires index (LevelDB) to find specific blocks quickly.

In the next section, we will look at the Magic Bytes and the internal structure of these files.

☕ Help support TeachMeBitcoin

TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation:

Ethereum: 0x578417C51783663D8A6A811B3544E1f779D39A85
Bitcoin: bc1q77k9e95rn669kpzyjr8ke9w95zhk7pa5s63qzz
Solana: 4ycT2ayqeMucixj3wS8Ay8Tq9NRDYRPKYbj3UGESyQ4J
Address copied to clipboard!