pq is a tool which deserializes protobuf messages given a set of pre-compiled .fdset files. It can understand varint/leb128-delimited/i32be streams, and it can connect to Kafka.
pq will pretty-print when outputting to a tty, but you should pipe it to jq for more fully-featured json handling.
pq is on crates.io: cargo install pq. You can also download a static binary from the releases page.
Put your *.fdset files in ~/.pq:
$ protoc -o dog.fdset dog.proto
$ protoc -o person.fdset person.proto
$ cp *.fdset ~/.pq/
Decode a single protobuf message:
$ pq --msgtype com.example.dog.Dog <./tests/samples/dog
{
"age": 4,
"breed": "poodle",
"temperament": "excited"
}
Decode a varint-delimited stream:
$ pq --msgtype com.example.dog.Dog --stream varint <./tests/samples/dog_stream
{
"age": 10,
"breed": "gsd",
"temperament": "aggressive"
}