How to Decode a gRPC Response Body (Frames, Gzip, Streams)
You have the body bytes of a gRPC response, from a proxy, a packet capture, or a test that dumped the raw response, and it is not JSON. The first surprise for most people is that those bytes are not protobuf. There is a transport layer on top of the message, and until you account for it, every decoder you point at the bytes either fails or returns garbage.
Every gRPC frame starts with five bytes: a one-byte compression flag, then a four-byte big-endian length, then the actual protobuf message. That is the whole framing. It is also the reason a raw gRPC body handed to an ordinary protobuf decoder breaks: the decoder reads the flag byte and the four length bytes as if they were message fields, so the field numbers come out wrong from byte one. The five-byte header has no way to be told from real field data by the message itself, which is exactly why it is specified separately.
Then there is compression, which is the second silent failure. When the flag byte is 1, the payload after the length is gzip-compressed, and gzip is the only compression gRPC supports. Servers enable it by default more often than you would expect, so it is not an edge case you can skip. A decoder that strips the header but not the gzip hands you back a blob that is valid-looking bytes of pure compressed data, and you will stare at it and think your schema is wrong. It is not. The bytes are just still wrapped in one more layer.
The case that catches people hardest is streaming. A server-streaming RPC returns N messages, and on the wire that is N frames concatenated in the same response body, one after another, with no separator other than each frame carrying its own length. A body that decodes cleanly into a message but then leaves bytes left over is almost always a stream. The correct answer for that body is a JSON array with one entry per frame, not a single object, and most tools will quietly decode the first frame and tell you nothing about the rest.
The fix is small if you have the right step order: strip the frame header, gunzip when the flag says so, walk every frame in the body, decode each one with the schema, and keep them apart in the output. That is exactly what the decode tab at proto.datajutsu.com does with a .proto and your body, as hex or Base64. Detection is strict on purpose: the declared length has to fit in the bytes actually remaining, and the flag has to be 0 or 1, so a genuine protobuf payload that happens to start with 0x00 or 0x01 is not mistaken for a frame. Compressed frames get gunzipped before decode and the output says so. Streams come out as a JSON array, one entry per message, with the flag and per-frame sizes named in the note above it. No schema at all? The raw decode tab reads the wire structure field by field, which is how you start when you do not know what is coming at you, as covered in reading a .pb file without the schema.
Two facts worth keeping while you work through your own captures. Sixty-four-bit integer fields come out as decimal strings in the JSON output, per the official protobuf JSON mapping, because a 13-digit order ID does not survive a JavaScript number. And the whole thing runs in the browser, so your schema and your captured body never touch a server, which matters when the body is a production response you are not supposed to be sitting on. The wire-format background for all of this, field numbers, wire types, why the names are not on the wire, is in what protobuf actually is.