Protobuf or Protocol Buffers is a binary serialisation format that needs type definition beforehand. It’s created by Google. This allows to omit structure from the data serialised, as client and server know what it is about.
Protocol buffers are a language-neutral, platform-neutral extensible mechanism for serializing structured data.
Protocol buffers | google developers (no date) Google. Google. Available at:
https://developers.google.com/protocol-buffers (Accessed: January 13, 2023).
To demonstrate how it’s working, I’ve recreated the same structure as in the JSON page.
A type in protobuf is called a message. Messages are defined in a .proto file. Let’s create a list of people, and see how it’s serialised compared to JSON.
The score for proto is 93 bytes, and 207 for JSON.
Info
When a protobufjs object like Person or Personlist gets serialised as JSON, like the last line in the script above, then it uses the JavaScript equivalent, so the result is not biased.
With a few more line, we can infer what the proto-serialised message look like: