The Role of blk.dat Files
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.
-
Once
blk00000.datreaches ~128MB, the node createsblk00001.dat. -
This makes it easier to move, copy, or verify the blockchain data in chunks.
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.
-
The file contains the Block Header.
-
The file contains the full list of Transactions.
-
The file contains the Witness Data (if applicable).
4. Location on Disk
By default, these files are located in the blocks/ subdirectory of your Bitcoin data directory:
-
Linux:
~/.bitcoin/blocks/ -
Windows:
%APPDATA%\Bitcoin\blocks\ -
macOS:
~/Library/Application Support/Bitcoin/blocks/
| 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.
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: