> ## Content Index
> Fetch the complete content index at: https://datajutsu.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to Build a gRPC Request Body (The 5-Byte Frame, Hand-Made)
- URL: https://datajutsu.com/build-grpc-request-body/
- Published: 2026-10-20T19:47:25.000Z
- Updated: 2026-10-20T19:47:25.000Z
- Author: Data Jutsu

You have the protobuf message encoded and you are about to send it as a gRPC request body, and the body you build is the message bytes. It is not. Every gRPC request body is a frame, not a message: five header bytes in front of your payload, and a server that gets the message bare either rejects it or reads the first bytes of your payload as a header and corrupts the decode. The good news is the framing is five bytes total and fully deterministic, and the bad news is nobody's tutorial makes you build it by hand, so the first time you do it with raw HTTP you get it wrong in one of two predictable ways.

The header is a one-byte compression flag, zero for no compression, then a four-byte big-endian unsigned length of the payload that follows. That is the whole format. Build it for a seven-byte message with no compression and the body is 00 00000007 plus those seven bytes, twelve bytes on the wire. Two mistakes account for nearly every failure. The first is little-endian length, because most of the rest of your tooling is little-endian and you reach for the same function. A server reading big-endian sees a length of about 86 megabytes for a seven-byte payload and either hangs waiting for bytes you never send or errors on the mismatch. The second is forgetting the flag byte entirely and shipping four length bytes plus payload. The server then reads your first payload byte as the compression flag. If that byte is 0x0a, a common protobuf tag, the flag is 10, which is not a valid flag value, and the request fails for a reason that is hard to connect to the cause.

Compression adds one layer. When the flag byte is 1, the payload after the length is gzip-compressed, and gzip is the only mechanism gRPC supports. Whether your server uses it is controlled by the Message-Encoding header on the exchange, not by the flag alone: the flag must only be 1 if you actually declared gzip on that call, and it must be 0 if you did not. A flag of 1 without the header, or a gzip payload with a flag of 0, are both protocol violations that surface as decode errors on the other side. For a test or a capture replay you do not need compression at all, and flag 0 with the uncompressed message is the simplest correct body.

The reverse direction is the same format, which is why the failure modes mirror: a response body you decode without stripping the five bytes gives you a message with phantom fields in front, and that is the problem the decode side of this tool exists for, covered in [decoding a gRPC response body](https://datajutsu.com/decode-grpc-response/).

If you are building these bodies in a browser or a quick script rather than through a gRPC library, the encode tab at [proto.datajutsu.com](https://proto.datajutsu.com/?ref=datajutsu.com) does the framing for you: paste the .proto and the JSON, encode the message, tick the wrap option, and the output is the exact request body to send, uncompressed or gzip, with the flag and both sizes named above it. Download it, send it with the Content-Type application/grpc header, and paste the response body back into the decode tab to close the loop. The whole thing runs in the browser, so the schema never leaves the machine.

One rule to keep while you work: the length counts the payload exactly as it is on the wire, compressed if you compressed, not the message before compression. Get that part wrong and every server you test against will behave differently depending on whether it validates eagerly, which makes the bug look flaky when it is not.