> ## 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.

# A Protobuf Default Is Not on the Wire (and the Tool Just Invented It)
- URL: https://datajutsu.com/protobuf-defaults-are-not-on-the-wire/
- Published: 2026-10-29T11:41:06.000Z
- Updated: 2026-10-29T11:41:06.000Z
- Author: Data Jutsu

I fed the decode tab a two byte message, 0805, one int32 field set to five, and it printed seven keys back at me. The integer five was real, the other six were not. The string was an empty string, the boolean was false, the float was zero, the repeated field was an empty array, and the submessage was null. None of those values were in the two bytes I handed it. The decoder did not find them, it invented them, and the output looks exactly as trustworthy as the one value that actually traveled. That is the whole story of the protobuf default, and it runs in both directions.

The wire has no defaults in it at all. A message where nothing is set encodes to zero bytes, no marker, no placeholder, nothing to say this field exists at its default. I measured the engine the tool runs on, and it does the opposite of the language most people know. The standard C++ and Go encoders skip a field that holds its default, they treat your intent as if the field were not there. The JavaScript engine here writes it. I encoded the same field at its default four ways and got four different tags on the wire: 0800 for the zero integer, 1a00 for the empty string, 2000 for the false boolean, 2d00000000 for the zero float. It even writes the defaults inside a submessage, an inner message at all defaults goes out as 32020800, three bytes to say nothing. So the same intent, a field at its default, produces different bytes depending on which language your sender is written in, and the receiver cannot tell which happened unless it knows the sender. A C++ client sends 0805 for that two field message, the JavaScript client sends 08051a00, and both mean the same thing.

The decode side is where the invention happens, and it is a flag, not a mystery. The decoder itself writes only what the bytes carry, a field appears in the decoded object only if its tag was on the wire. The step that fills in the rest is the plain object conversion with defaults turned on, and that is exactly what the tool runs. I verified it in the page source, the decode tab converts with defaults on, which is why an empty two byte message prints a full skeleton and a message field that never arrived prints as null instead of a fake submessage. Turn the flag off and the same two bytes print a single key, just the five. The output you are looking at is a choice the reader made, and every protobuf implementation makes that choice differently, which is why the same bytes can render as one key in one tool and seven in another.

So what is the actual signal that a field was sent? The tag, and only the tag. I encoded the five with the string field left out and with the string field explicitly empty, the first gave 0805, the second gave 08051a00, and on the way back the first shows no string key while the second shows the empty string. Presence is not a value, it is a two byte address on the wire. Repeated fields split the same way. A repeated submessage that is present but empty, a zero length slot, decodes as an empty object in the array, the slot survived, and a repeated list that was never sent decodes as nothing. The packed scalar list is the ambiguous one: a list containing one zero is three bytes, 3a0100, and it decodes as a list with a zero in it, but a reader running with defaults on prints an absent list as an empty array, so the zero item and the no list can look identical in the JSON even though the bytes disagree.

The one field kind that resolves the ambiguity is the explicit optional, and the resolution is a null. I declared the same integer two ways, plain and optional, and decoded an empty message with defaults on. The plain field printed zero, its type default, invented. The optional field printed null, nothing, because the optional keyword is the one thing that puts a presence marker on the wire when you do send it. The catch is that the marker carries presence, not a value, so an optional integer you deliberately set to zero writes 0800 and decodes back as zero, indistinguishable in the JSON from the plain field that never arrived and got its default. The optional post in this series walks the wire mechanics of that marker, and the [https://datajutsu.com/protobuf-required-presence/?ref=datajutsu.com](required post) is the one rule word the decoder enforces on its own, throwing on a missing field instead of inventing one. [https://datajutsu.com/how-protobuf-wire-format-works/?ref=datajutsu.com](How the wire format works) is where the tag byte comes from in the first place.

So the default value is not a protobuf concept, it is a promise between your schema and whoever reads the bytes, and the wire just stays silent about it. The [https://proto.datajutsu.com/?ref=datajutsu.com](decode tab) prints the promise, the invented skeleton, because a UI is cleaner with every field visible, and the [https://proto.datajutsu.com/?ref=datajutsu.com](encode tab) is the side where your language decides whether your defaults ride the wire or not. If you are reading JSON out of the tool and a field shows zero, empty, or null, the bytes alone cannot tell you whether it was sent or promised, and the only way to know is to look at the tags, or to use the optional keyword where presence has to mean something. The [https://datajutsu.com/protobuf-json-mapping/?ref=datajutsu.com](JSON mapping post) is where the same default question shows up on the other door, and [https://datajutsu.com/protobuf-silent-loss-both-directions/?ref=datajutsu.com](the silent loss post) is what happens when the schema itself disagrees. Defaults never cross the wire, they cross the reader.