How to Convert JSON to Protobuf (No Compiler Needed)
You have JSON and the other end speaks protobuf. Maybe it is an API that only takes .pb bodies, maybe you are mocking a gRPC response for a test, maybe a team handed you a config as JSON and the system wants the binary form. The usual answer is the same as everything else in this ecosystem: write the .proto file, install protoc, write a little script that maps your JSON onto the message types, run it, hope the field numbers are right. All of that to get a few hundred bytes.
The reason it feels heavier than it should is that protobuf and JSON are honestly mismatched. A protobuf field is not a key, it is a field number. On the wire every field is a tag followed by a value: the tag is one varint packing the field number together with a three-bit wire type, and the wire type says how the value is stored (varint, fixed 64, a length-delimited chunk, fixed 32). Repeated fields are just the tag appearing more than once. None of that is in your JSON, so encoding always needs a .proto that tells you the numbers and types, plus a mapping for the values you actually have. Get the mapping wrong and nothing errors, the bytes just mean something different to the reader.
The mistakes that actually show up are boring and consistent. Your JSON keys are snake_case and the schema says camelCase, or the reverse, and the encoder silently ignores half your fields. You pass an int64 as a number and it loses precision, because the official protobuf JSON mapping carries 64-bit integers as strings and a correct encoder has to accept both. You hand it an enum as the string USER and it needs to know that is 1 in your schema. And the round trip has a real gotcha: an empty repeated field encodes to zero bytes, so a list you set to empty will not exist when you decode what you just encoded. That is not a bug, that is the wire format. But it is exactly the kind of thing you want to see, not discover in production.
The encode tab at proto.datajutsu.com skips the whole install: paste your .proto and your JSON, and it hands you the binary as base64, hex, or a .bin download, running entirely in the browser. It handles the key mapping both directions, enums given as strings, 64-bit ints as strings or numbers, nested messages, and repeated fields. And if you do not have a schema at all, the JSON to .proto tab drafts one from your data, and the Verify button is the part I care about most: it takes your drafted .proto, encodes the original sample with it, decodes it back, and diffs it field for field. Green means the schema you guessed actually carries your data. That is proof, not a guess, and it is the difference between a draft you can trust and one you find out about later.
Reading binary is the mirror image of all this, and this post covers that side (and this one covers what you can do to a .pb file with no schema at all). Everything here is in-browser, nothing you paste gets uploaded, and a share link puts your exact inputs in the URL so you can send someone the case that is breaking you. Free, no account, no compiler, no ticket queue.