The format is defined by the OpenStreetMap wiki page
“PBF Format” (read
2026-11-13) and two
Protocol Buffers files from the OSM-binary
project, fileformat.proto
and osmformat.proto
(proto2, package OSMPBF; read 2026-11-13). The number before each field is its Protocol Buffers field
number. In fileformat.proto, block types starting with an underscore (_) are reserved.
Blocks
- 4 bytes, big-endian: length of the BlobHeader. The wiki says it should be less than 32 KiB and must be less than 64 KiB.
- The
BlobHeadermessage. - The
Blobmessage,datasizebytes long. The wiki limits the uncompressed length of a Blob: it should be less than 16 MiB and must be less than 32 MiB (to detect illegal or corrupt files).
| Message | Fields |
|---|---|
BlobHeader | 1 type (string, required): OSMHeader or OSMData; 2 indexdata (optional bytes: an arbitrary blob that may carry metadata about the following blob, for example a bounding box for OSM data; a stub reserved for the future design of indexed .osm.pbf files); 3 datasize (int32, required). |
Blob | 2 raw_size (int32): size when uncompressed. One of: 1 raw, 3 zlib_data (zlib format, not raw deflate or gzip), 4 lzma_data, 5 OBSOLETE_bzip2_data, 6 lz4_data, 7 zstd_data. |
All readers and writers must support uncompressed and zlib data; the other
compressions are optional and not widely used. An OSMHeader block must
come before the first OSMData block, and parsers skip block types they
do not recognise.
HeaderBlock
| Field | Meaning |
|---|---|
1 bbox | HeaderBBox: 1 left, 2 right, 3 top, 4 bottom, all required sint64, always in nanodegrees: osmformat.proto says they do not obey the granularity rule. The whole message is optional. |
4 required_features | Strings a reader must understand: OsmSchema-V0.6, DenseNodes, HistoricalInformation (file holds old versions). A reader that meets a required feature it does not understand must reject the file with an error and report which required features it does not support. |
5 optional_features | Hints; a reader that meets an optional feature it does not know can still safely read the file (one that expects an optional feature that is absent may error out). Has_Metadata, Sort.Type_then_ID, Sort.Geographic, timestamp=…, LocationsOnWays. |
16 writingprogram | The program that wrote the file. |
17 source | Source of the data (“From the bbox field”, says the wiki’s comment). |
32 osmosis_replication_timestamp | Replication timestamp, in seconds since the epoch. |
33 osmosis_replication_sequence_number | Replication sequence number (sequenceNumber in Osmosis’s state.txt). |
34 osmosis_replication_base_url | Replication base URL (from Osmosis’s configuration.txt). |
PrimitiveBlock
| Field | Meaning |
|---|---|
1 stringtable | StringTable: 1 s, repeated bytes. Entry 0 is empty and used as a separator; keys, values, user names and roles refer to entries by index. |
2 primitivegroup | Repeated. Each group holds one kind only: 1 nodes, 2 dense, 3 ways, 4 relations or 5 changesets. |
17 granularity | Nanodegrees per coordinate unit; default 100. |
19 lat_offset, 20 lon_offset | Nanodegrees added to every coordinate; default 0. |
18 date_granularity | Milliseconds per timestamp unit; default 1000. |
Latitude in degrees = 10−9 × (lat_offset +
granularity × lat), and the same for longitude.
Elements
| Message | Fields |
|---|---|
Node | 1 id (sint64), 2 keys, 3 vals (packed uint32 string indexes), 4 info, 8 lat, 9 lon (sint64). |
DenseNodes | 1 id (packed sint64, delta-coded), 5 denseinfo, 8 lat, 9 lon (packed sint64, delta-coded), 10 keys_vals (packed int32: key, value string ID pairs for each node, each node ending with 0, ( (keyid valid)* 0 )*; may be empty if every node in the block is tagless; denseinfo is the metadata, which may be omitted). |
Way | 1 id (int64), 2 keys, 3 vals, 4 info, 8 refs (packed sint64 node IDs, delta-coded), 9 lat, 10 lon (optional packed sint64, delta-coded node positions; when used the writer MUST set the optional feature LocationsOnWays and refs, lat and lon MUST have the same number of values; the files are larger but give way geometry directly). |
Relation | 1 id, 2 keys, 3 vals, 4 info, 8 roles_sid (packed int32 string indexes; the proto says it should have been uint32 for consistency but it is too late to change), 9 memids (packed sint64, delta-coded), 10 types (packed MemberType: 0 NODE, 1 WAY, 2 RELATION). |
ChangeSet | 1 id (int64, required). The only field; osmformat.proto says it “is kept for backwards compatibility but not used anywhere”. |
Metadata
| Message | Fields |
|---|---|
Info | 1 version (int32, default −1), 2 timestamp (int64, in date-granularity units), 3 changeset (int64), 4 uid (int32), 5 user_sid (uint32 string index), 6 visible (bool: history data; it says the object version was created by a delete on the OSM API; a writer that sets it MUST add the required feature HistoricalInformation, and when it is not available for an object it must be assumed true if the file has that feature). |
DenseInfo | The same fields as packed arrays, one entry per node: 1 version (int32), then delta-coded 2 timestamp (sint64), 3 changeset (sint64), 4 uid (sint32), 5 user_sid (sint32 string IDs); 6 visible (bool, packed, the same rule as in Info). |
Delta coding: the first value is stored as it is, each later one as the difference
from the one before, all zigzag-encoded (sint64).