Protobuf & Avro Schema Viewer · Tutorial
How to read a .proto file and get a sample JSON message
7 min readintermediateUpdated
You have joined a project that talks to a gRPC service and need to understand its .proto file quickly. This tutorial uses the Protobuf & Avro Schema Viewer to explore the messages, enums and service methods, check the file for mistakes and produce a sample JSON message to use in tests.
What you need
- The Protobuf & Avro Schema Viewer
- A
.protofile, or the sample order service from the Try it button
Steps
Paste the schema
Paste the
.protofile into the left box or open it. The summary reads 3 messages · 1 enum · 1 service · 12 fields · 2 methods, which gives you a sense of the size before you read any details.Explore the messages
Open
shop.v1.Orderon the right. Each field is listed with its number, name and type. Notes showrepeatedfor lists andoneof paymentforcard_tokenandvoucher_code, which means only one of the two can be set. Comments written above fields appear next to them.Look at nested types and enums
Order.LineItemand theOrder.Statusenum are defined insideOrder, so their full names include it. The enum lists each value with its number, starting withSTATUS_UNSPECIFIED = 0, as proto3 requires.Check the service
OrderServicehas two methods.GetOrdertakes aGetOrderRequestand returns anOrder.WatchOrdersreturnsstream Order, meaning the server sends a series of orders over time.Generate a sample message
Under Sample JSON, choose
shop.v1.Order. The example uses the JSON names that gRPC gateways and protobuf JSON libraries produce, such asorderId. The 64-bitprice_centsappears as a string, the enum by name and the timestamp in ISO format.{ "orderId": "text", "items": [{ "sku": "text", "quantity": 1, "priceCents": "123" }], "status": "STATUS_UNSPECIFIED", "createdAt": "2026-01-01T00:00:00Z" }Copy it into your tests
Press Copy and replace the placeholder values with realistic ones. Only one field of the
paymentoneof is included, because setting both would be invalid.
Try it yourself
Opens the Protobuf & Avro Schema Viewer with this tutorial's sample loaded.
Common mistakes
- Reusing a removed field number
- The sample reserves number 9 and the name
coupon. If you add a field with either, the viewer reports it. Old clients could misread the new field as the removed one. - Expecting imported types to be expanded
- Only the pasted file is read. Types from other imported files are shown by name, and flagged as warnings when they are not well-known types.
- Treating int64 as a JSON number
- In protobuf JSON, 64-bit integers are strings so no precision is lost. Send
"123", not123, to strict parsers.
Next steps
Go back to the Protobuf & Avro Schema Viewer, or keep going with one of these:
FAQ
Can I view Avro schemas the same way?
Yes. Press Load Avro example or paste an .avsc file. Records, enums, unions and defaults are shown, and sample JSON follows Avro's rules.
Why are field names different in the JSON?
The protobuf JSON mapping converts snake_case field names to lowerCamelCase. Most libraries accept both forms when reading.