About
Tool No. 69 of Pikkola
A protobuf payload is not a document. It is a run of tags and values with no names in it, and the names live in a file somewhere else. This page holds both halves and lets you move between them, in the browser.
What it does
Paste a payload as base64 or hex. The page reads it twice. The wire reading needs nothing else: it lists the field numbers, the wire type of each field, the byte offset where each one starts, and the bytes inside every length. The typed reading needs a .proto file and a message type: the same payload becomes a JSON document with the names and types from the schema, and that JSON can be edited and written back to bytes.
Four samples ship with the page: a gRPC request, a nested order, a profile full of maps and repeated fields, and a metrics sample with packed numbers. They are not decorative. Each one was serialized by the real protobuf library from the .proto shown beside it, and the build compares this decoder's output with that library's output.
The wire reading
Every field starts with a tag: a varint that packs a field number and a wire type. The wire type is three bits and says how the value is shaped. Zero is a varint. One and five are eight and four bytes. Two is a length followed by that many bytes. Three and four are the deprecated group pair, which is read as a block and kept as a byte range.
A length delimited field carries four possible things: a string, a message, a packed array, or bytes. Nothing on the wire separates them. The page picks a reading by trying them in order and shows which one it chose: printable UTF-8 is text, a payload that walks cleanly as a message is a message, a run of whole varints is a packed array, and anything else is bytes. A small chip on the row cycles the readings that apply, because a guess is still a guess.
A nested message has no end marker. Its length is the only thing that says where it stops, so the tree follows lengths and never guesses an end. Offsets are absolute: a field inside a nested message shows the byte where it starts in the whole payload, not in its own little buffer.
The typed reading
The schema parser reads proto2 and proto3: messages, nested messages, enums, oneof, map fields, repeated fields, all fifteen scalar types, field options, comments, packages and dotted type names. Imports are not fetched, because a page with connect-src none cannot fetch anything; a type from another file has to be pasted into the same box. Services and extensions are read past, since they do not change how bytes are laid out.
Decoding follows the field numbers in the schema. A field the schema knows becomes a typed value: an enum name rather than a number, a nested object rather than bytes, an array for a repeated field, an object for a map. A field it does not know is not thrown away. It arrives in $unknown with its wire type and its value, which is what you want when a service has shipped a new field before the schema reached you.
Integers are the one place where JSON gets in the way. A JSON number is exact up to 2^53. Above that, a 64 bit field is written as a decimal string, which is also what the protobuf JSON mapping does, and the encoder reads it back exactly. A float that is not finite is written as "NaN" or "Infinity", again following the mapping.
Writing bytes back
The encoder is the same schema read in reverse. Fields are written in field number order, scalars are range checked against their type, a value that does not fit stops the encoder with the path to it, and a key the schema does not name is reported rather than silently dropped. Repeated numeric fields are written packed unless the schema says [packed = false]. Map entries become the key and value message the wire expects. $unknown is ignored, so a round trip through the editor does not duplicate it.
The reference check in the build serializes all four samples with the protobuf library, decodes them with this page, and compares. The encoder's bytes are compared with the library's bytes for the same document.
gRPC
A gRPC message on the wire is a five byte header and then the protobuf message: one byte for the compression flag, four big endian bytes for the length. The page notices that shape when the length matches what follows, says so under the payload, and skips the header so the first field is read from the message rather than from the header. The header can be put back with the same button. A compressed frame is reported and not decompressed.
Where it stops
A payload up to 8 MB, a nesting depth of 64 levels, and 60,000 fields before the walk stops. A .proto up to 512 KB. When a limit or a malformed field stops the walk, the tree keeps what it read, marks the byte where it stopped, and says why. A tag that reads field number 0, a length that runs past the end, and a wire type of 6 or 7 are errors rather than fields, because treating them as fields would produce a tree that looks right and is not.
The decoder is JavaScript written for this page. It is not protobuf.js and it is not a protoc plugin. Where its output can be compared with the real implementation, the build does that comparison, and the samples on the page are the cases it is checked against.
Privacy
The payload is read by the browser, parsed by a script on this domain, and kept in memory for the life of the tab. It is never uploaded and never written to storage. The only things stored are the interface language and the theme, in localStorage. The privacy note has the detail.
Questions, or a payload that should decode and does not: hello@pikkola.com.