• Hash256
  • Hash160
  • Reverse Bytes
  • Hexadecimal
  • Satoshis

Magic Bytes

The message delimiter on the bitcoin network.

Magic bytes are used as a way to identify the separate messages sent between nodes on the bitcoin network.

For example, if you are trying to connect to a node with your own code, every message you send to that node should begin with f9beb4d9, and every message you receive from that node will start with the same magic bytes too.

The magic bytes.

Magic bytes are 4 bytes in length, and will be different depending on which network you’re on:

Network Magic Bytes
Mainnet f9beb4d9
Testnet3 0b110907
Regtest fabfb5da


Here’s a version message I received from a node on the Testnet3 network:


And here’s a tx message:


Magic bytes are also used to separate block data in the blk*.dat files.

Why use Magic Bytes?

If you connect to a bitcoin node, think of the messages you get from it as a continual stream of data.

Nodes receive data in streams of bytes. The f9beb4d9’s help you spot when a new message starts.

If you are trying to read this data, it’s good to have a reliable way of knowing when a new message starts (and ends). This is why a specific set of “magic bytes” are used as a “marker” so that you can always identify the start of a new message.

So there’s nothing actually magical about magic bytes – it’s just a way of segmenting data.

Why these bytes in particular?

These bytes have no specific meaning, except for:

The message start string is designed to be unlikely to occur in normal data. The characters are rarely used upper ASCII, not valid as UTF-8, and produce a large 32-bit integer with any alignment. – chainparams.cpp

So they could be different, but these are just 4 bytes that have the properties that make for good magic bytes on the bitcoin network.


By Greg Walker,

Last Updated: 04 Feb 2021
  • 04 Feb 2021: spelling fixes
  • 21 Jul 2020: renamed /guide/ to /technical/
Back to Top

Hey there, it's Greg.

I'll let you know about cool website updates, or if something seriously interesting happens in bitcoin.

Don't worry, it doesn't happen very often.