Data Serialization
I always read that JSON is text based and protobuf is binary. Still, one thing confused me. In the end, everything is binary.

Text Based
In text based methods like JSON, the whole payload is text. Every character is encoded with UTF-8 or some other encoding.
- Integers and decimals are also treated as characters. Each one is encoded.
- Even boolean values true and false are encoded as 4 and 5 characters.
- Every quote and bracket is encoded as a character.
Text based serialization provides human readability
These encoding methods make it easy to decode the whole payload and read the contents.
Binary Based
In binary based methods like Protobuf, the encoding aims to shrink the payload. It writes binary values for the data directly.
- Integers are fully converted to binary using VARINT.
- Decimals are converted to binary using IEE754 based floating point numbers.
- Strings are still encoded using UTF-8.
- Boolean as just 1 byte.
protobuf features
Binary encoding is just one protobuf feature. It has others too. For example, it can skip the key names. This shrinks the payload even more.