ProtoHelper is a lightweight helper for serializing and deserializing classes into Google Protocol Buffers (Protobuf) binary format — without needing to use the protoc compiler to generate schema files.
This makes it ideal for small projects or dynamic systems where you want to handle Protobuf data directly, without maintaining .proto definitions.
Unlike text-based formats (like JSON), Protobuf encodes data in a compact binary format.
Since no schema is used, the order of fields is critical — fields are written and read in the exact order they appear in the class.
If the order changes, the binary structure becomes invalid and cannot be properly deserialized.
In the example, we define three simple classes:
TContact– Represents a contact personTAddress– Represents a postal addressTCompany– Represents a company that containsTAddressand a list ofTContact
Each class can be serialized using ProtoHelper.Serialize() and deserialized using ProtoHelper.Deserialize().
The example demonstrates how to:
- Serialize a class instance (including nested objects)
- Save the binary data to a
.pbfile - Read the
.pbfile from disk - Deserialize it back into a class instance
You can inspect and decode the .pb files generated with this helper at:
👉 https://protobuf-decoder.netlify.app/
This tool allows you to view the raw Protobuf structure and verify that your serialization is working as expected.
- No
.protoschema orprotoccompiler needed - Easy to integrate into existing projects
- Supports nested classes and collections
- Portable binary format compatible with other Protobuf tools
- Maintain consistent field order between serialization and deserialization.
- Use the same class structure across all environments reading or writing the data.
- Any change in field order or type may break compatibility with previously saved
.pbfiles.
😉 Simple, schema-free, and powerful — that’s ProtoHelper.