Skip to content
DonateБГ

Bitcoin from zero

Data

Bitcoin's raw data is a stream of bytes. Learn bytes, hex, byte order and compact size, the basics every technical page builds on.

By Dimitar Zurnov · Updated 4 Nov 2026
Adapted from Learn Me a Bitcoin by Greg Walker.

Bitcoin's raw data is a long string of bytes. A transaction, a block header and a network message are each a fixed sequence of fields, and every field has a size measured in bytes. Open a raw transaction and you see hex digits, numbers stored backwards and short length prefixes. This section explains those conventions.

Why does raw data need its own conventions?

Bitcoin software stores and sends data as bytes, not as text. A byte is eight bits, and it has no fixed meaning until a field says what it holds. The same eight bits can be a number, a letter or part of a hash. So each page here explains one convention before you meet it in a transaction or a block.

What does this section cover?

  • Bytes: eight bits, the unit that raw data is measured in.
  • Hexadecimal: the base-16 digits that write each byte as two characters.
  • Byte order: why transaction IDs and block hashes appear reversed.
  • Little-endian: the backwards order used for numbers in raw data.
  • Compact size: the variable-length counts and lengths that take one to nine bytes.

Which order should you read it in?

Read the pages in this order. Each one uses the words of the page before it.

  1. Bytes: what a byte is and how it is read.
  2. Hexadecimal: the digits that show bytes in a compact form.
  3. Byte order: the natural and reverse orders of hashes.
  4. Little-endian: how numbers are stored in raw data.
  5. Compact size: the prefix that lets a count take one byte or more.

Once these make sense, the private key and the fields of a transaction will be easier to read.

In this section

  1. 1BytesBytes in Bitcoin: a byte is eight bits, written as two hex digits. Learn the sizes of keys, IDs, amounts and the fields in blocks.
  2. 2HexadecimalHexadecimal in Bitcoin: a base-16 system with the digits 0 to 9 and A to F, used to write bytes. Learn to read and convert hex.
  3. 3Byte orderByte order in Bitcoin: TXIDs and block hashes show their bytes reversed in explorers and RPC. Learn both orders and when to use each.
  4. 4Little-endianLittle-endian in Bitcoin stores the least significant byte first. Most numbers in raw transactions and block headers use it. Learn to read them.
  5. 5Compact sizeCompact size in Bitcoin stores a count or length in one to nine bytes. Values from 253 use an FD, FE or FF prefix. See the full table.

Something look wrong? Tell us