JSON vs Protocol Buffers
People think Protobuf is just a faster JSON, and it is not. JSON carries its own field names, so anyone can read it with no setup. Protobuf sends only numbered fields as bytes. Both sides need the same .proto file to make sense of them. You trade easy reading for small, fast messages.
JavaScript Object Notation (JSON)
A plain text format for data, made of names and values. Most APIs use it.
JSON is a plain text way to write down data so programs can swap it. It uses names and values in curly brackets, like "age": 36. It can hold text, numbers, true or false, null, lists and nested groups. Almost every language can read and write it. Most web APIs send and receive their data as JSON.
Protocol Buffers (Protobuf)
A compact way to send data as bytes. It is smaller and faster than JSON.
Protocol Buffers is a format from Google for sending data as compact bytes. You first describe the data in a .proto file. A tool turns that file into code for your language. That code packs data into small bytes and unpacks it again. It works like JSON, but it is smaller and faster to read. The catch is that people cannot read the bytes.
In one line
- JavaScript Object Notation (JSON)
- A plain text format for data, made of names and values. Most APIs use it.
- Protocol Buffers (Protobuf)
- A compact way to send data as bytes. It is smaller and faster than JSON.