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

Steps

  1. Paste the schema

    Paste the .proto file 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.

  2. Explore the messages

    Open shop.v1.Order on the right. Each field is listed with its number, name and type. Notes show repeated for lists and oneof payment for card_token and voucher_code, which means only one of the two can be set. Comments written above fields appear next to them.

  3. Look at nested types and enums

    Order.LineItem and the Order.Status enum are defined inside Order, so their full names include it. The enum lists each value with its number, starting with STATUS_UNSPECIFIED = 0, as proto3 requires.

  4. Check the service

    OrderService has two methods. GetOrder takes a GetOrderRequest and returns an Order. WatchOrders returns stream Order, meaning the server sends a series of orders over time.

  5. 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 as orderId. The 64-bit price_cents appears 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"
    }
  6. Copy it into your tests

    Press Copy and replace the placeholder values with realistic ones. Only one field of the payment oneof is included, because setting both would be invalid.

Try it yourself

Opens the Protobuf & Avro Schema Viewer with this tutorial's sample loaded.

Try it now

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", not 123, 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.