Take the 2-minute tour ×

I'd like to find a way to convert a binary protobuf message into a human readable description of the contained data, without using the .proto files.

The background is that I have a .proto message that it being rejected by the parser on Android, but it's not entirely clear why. I could go through the message by hand, but it's rather tedious.

I found the --decode_raw option to protoc, but it just gives the error "Failed to parse input.". I google hoping/expecting someone would have done a nice web utility that might do this, but haven't found anything obvious.

I'm just hoping to get some output like:

field 1: varint: 128
field 4: string: "foo"

Any pointers in the right direction would be most welcome!

share|improve this question
Is there a possibility that the message contains some header attached to it? Try decoding it after skipping the first 1,2,3,4... bytes. –  alavrik Sep 8 '11 at 15:48
One of the problem messages was actually only 4 bytes: 18, 4, 48, 0 (decimal). (Maybe it's actually got truncated?) –  JosephH Sep 9 '11 at 6:16
18 = "field 2, length-prefixed" (probably meaning: sub-message), 4 = 4 (the length of the next fragment, in bytes), 48 = "field 6, varint", 0 = 0. So you are missing at least 2 bytes (the advertised sub-message size is not satisfied) –  Marc Gravell Sep 9 '11 at 6:46
That would certainly explain why I'm having problems - thanks Marc! –  JosephH Sep 14 '11 at 11:16
add comment

2 Answers

up vote 2 down vote accepted

You could try forcing it through the wireshark plugin, or you could probably borrow the "reader" part of some of the implementations (I know how I would do this in C#, for example, but I doubt that is what you meant).

However, be cautious - string in protocol buffers doesn't really mean "string" - it could be:

  • a UTF-8 string
  • a raw BLOB of arbitrary data
  • a sub-message
  • a "packed" array
  • (probably something else I'm forgetting)
share|improve this answer
Thanks Marc! I hadn't appreciated that the string and sub-message etc are not distinguishable without the .proto (though I suppose you could make a heuristic based guess) –  JosephH Sep 9 '11 at 6:32
@JosephH yeah, you could try UTF-8 - you'd get pretty close if it works; the others are trickier though... –  Marc Gravell Sep 9 '11 at 6:42
add comment

For Posterity: Google's protocol buffer tools have the ability to decode raw buffers.

Just send the unknown buffer to it and pass the--decode_raw flag

$ cat has_no_proto.buff | protoc --decode_raw
2 {
  2: "Error retrieving information from server. [RH-02]"

So here's a message with field 2 set to an embedded message which in turn has its second field set to a string telling me I pissed off Google Play.

Type information isn't definite (it looks like it will try to display all binary data as strings -- but your requirement for varint/string/submessage distinction is met).

share|improve this answer
What is the format of the .buff file? I have a binary file containing just the raw protocol buffer bytes but keep getting "Failed to parse input." –  DeepSpace101 Oct 28 '13 at 21:57
In this case it was raw protocol buffer byte output. Are you certain your file is correct? (look out for magic bytes added by editors) –  anq Nov 4 '13 at 1:37
add comment

Your Answer


