What Is Protobuf and How Does It Work?
Protobuf is a binary format for structured data that Google built for shoving records across the wire. You describe your data types once in a .proto file, and from then on every machine that has that file can write your records as a few bytes instead of a few hundred, and read back exactly what was written. It is the format underneath gRPC, in a lot of message queues, in game servers, in databases like Cassandra and Scylla. If you have been handed a .pb file or a binary body with no documentation, you have hit it.
Here is how it actually works, because the mental model is simple once you have it. In your .proto file you define a message type: each field gets a name, a type, and a number. The number is the identity. On the wire the name never exists at all, every field is written as a tag followed by a value, and the tag is one varint that packs the field number together with a three-bit wire type. There are only four wire types: varint, fixed 64-bit, length-delimited, and fixed 32-bit. A string is a length-delimited chunk (its length, then its bytes). A repeated field is just the same tag appearing more than once. So {name: "Rafik", age: 42, tags: ["test"]} becomes a few dozen bytes of tags and values with no keys, no quotes, no braces. You can look at any .pb file with a hex editor and follow it by hand; the numbers are right there.
Why is it smaller than JSON, honestly? Because JSON repeats the key names in every single record, writes every number as text, and wraps everything in structure characters. Protobuf writes the field number once per field per record and stores values in their native binary form. For a record you send millions of times a second, that adds up fast, and parsing binary is cheaper than parsing text. It is worth being clear about the limits though: for one small message the saving is modest, and the format buys you nothing unless both ends have the schema. The speed and size are real, but they come from the repetition, not from magic.
The catch is that protobuf is only readable if you have the .proto file. That is the whole game. And the official protobuf JSON mapping has quirks that bite people when they first try to bridge the two: 64-bit integers are carried as strings, an empty repeated field encodes to zero bytes so it disappears on the round trip, and field names can be snake_case in the schema and camelCase in the JSON. None of these error out. They just produce bytes that mean something different to the other side. Half of protobuf support tickets in the world are one of these three.
The practical side is better than it used to be, because you no longer need to install a toolchain to find out what is in a file or to move data between the two formats. The converter at proto.datajutsu.com runs entirely in the browser: paste a .proto and a binary and get JSON, run a file with no schema at all through the raw decode to reconstruct what the message looked like, draft a .proto from JSON you have on hand and verify with a real encode-decode round trip that it carries your data, or generate typed clients in TypeScript, Python, Go, and Rust. It is free, and nothing you paste ever leaves the page.
If you already know what protobuf is and want the concrete how-tos: converting a .pb file to JSON with the schema, reading one without any schema, and encoding JSON back to binary. Each one has the specific failure modes that actually show up, not the textbook version.