wtf series - wtf is protobuf?

This is part of a series of posts explaining cryptic tech terms in an introductory way.

Disclaimer: this series is not intended to be a main learning source. However, there might be follow up posts with hands-on experiments or deeper technical content for some of these topics.

Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages. [src]


One of the oldest data serialization standards driven from the SGML, the Standard Generalized Markup Language. Standardized 1996~1998, XML was the primary structured and semi-structured data serialization standard and the basis for SOAP protocol. It's human-readable, structured and very verbose. [snippet src]

<?xml version="1.0" encoding="UTF-8"?>
    <name>Belgian Waffles</name>
   Two of our famous Belgian Waffles with plenty of real maple syrup
    <name>Strawberry Belgian Waffles</name>
    Light Belgian waffles covered with strawberries and whipped cream
    <name>Berry-Berry Belgian Waffles</name>
    Belgian waffles covered with assorted fresh berries and whipped cream
    <name>French Toast</name>
    Thick slices made from our homemade sourdough bread
    <name>Homestyle Breakfast</name>
    Two eggs, bacon or sausage, toast, and our ever-popular hash browns

Short for JavaScript Object Notation, popularized around early 2000s was a step forward for data representation and serialization as it was less verbose than XML, easier to support on browsers, faster to process and it enforces consistent structure. This made it the main data serialization standard for the modern web for long years.

// simple representation of a breakfast menu with only one item
    "name": "Homestyle Breakfast",
    "price": "$6.95",
    "description": "Two eggs, bacon or sausage, toast, and our ever-opular hash browns",
    "calories": 950

Protocol buffers (protobuf)

Google developed Protocol Buffers for use in their internal services. It is a binary encoding format that allows you to specify a schema for your data using a specification language, like so:

message Person {
  required string name = 1;
  required int32 id = 2;
  optional string email = 3;

The Protocol Buffers specification is implemented in various languages: Java, C, Go, etc. are all supported, and most modern languages have an implementation. Here is a Java example using the previous schema:

Person john = Person.newBuilder()
    .setName("John Doe")
output = new FileOutputStream(args[0]);
Person john;
fstream input(argv[1],
    ios::in | ios::binary);
id =;
name =;
email =;

Using protocol buffers has many advantages over plain text serializations like JSON and XML:

  • Very dense data which result in very small output and therefore less network overhead
  • Declared schema makes parsing from most languages very straightforward with less boilerplate parsing code
  • Very fast processing
  • Binary encoded and hard to decode without knowledge of the schema
  • Backward compatibility as a side-effect


Google developers - Protocol Buffers

Essam Hassan

Essam Hassan

A pragmatic software engineer, cyber security enthusiast and a Linux geek. I curse at my machine on a daily basis. My views are my own.
Zurich, Switzerland