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

# Protobuf Fixed32 and Fixed64 Are the One Value the Wire Reverses (and Nobody Checks Which One You Mean)
- URL: https://datajutsu.com/protobuf-fixed-wire-endianness/
- Published: 2026-10-23T04:55:56.000Z
- Updated: 2026-10-23T04:55:56.000Z
- Author: Data Jutsu

Of the four wire types, the two fixed ones are the only ones where the order of the bytes inside the value is a rule instead of a side effect, and the rule is little-endian: the low byte comes first. I wrote a fixed32 field holding 16909060, which is 0x01020304, and the four value bytes on the wire are 04 03 02 01, the number backwards. The full field is tag 0d plus those four bytes, 0d04030201\. A reader that assumes big-endian, the default assumption for most of the rest of computing, makes 0x04030201 out of the same four bytes, a number that is 67305985, and reports it without any complaint, because every single byte was present and in a plausible position. protoc 25.3 writes the same byte order and reads it back, and the JS library in the browser tool writes and reads it the same way, so the wire itself interoperates. It is the hand-written reader and the pasted hex dump where the endianness bites, and it bites exactly once per field, which makes it easy to miss in a code review and easy to find in a diff of decoded values.

The wire type also turns out to be less enforced than the name suggests, because the tag says how many bytes to read and the schema says what those bytes mean, and when the two disagree the two decoders disagree with each other. Take the four-byte fixed32 encoding of 16909060, tag 0d plus 04 03 02 01, and put it under a schema that declares that field a uint32\. The C++ decoder follows the tag: it reads the four bytes the wire type promises and interprets them as the declared type, so the value comes back as 16909060, a fixed32 number read as a uint32, exit code zero. The JavaScript decoder follows the schema: the field is declared a varint, so it reads the tag 0d plus the next byte 04 as a two-byte varint that yields 13, a perfectly plausible wrong number, and then runs off the end of the buffer on the leftover bytes. Same five bytes, one decoder hands you the number and the other hands you 13, and neither of them checked the thing that would have settled it. Where the two agree, because the declared type and the tag name the same four-byte width, the answer is a float reading of a fixed32: the bytes for fixed32 one under a field the schema calls a float come back as 1.401298464324817e-45, the smallest positive denormal, in both. The C++ decoder goes furthest on a cross-family mismatch: an 8-byte fixed64 field that lands on a field the schema declares a uint32 is read as eight bytes per the tag and printed as 1, a number the schema never meant to hold. The raw decode tab is built on exactly the lesson underneath all of this: the tag tells you the width, the bytes are the bytes, and which reading is the right one is a question only your schema can answer, so it shows every reading side by side instead of picking one.

Fixed has a price, and the price is a constant. A fixed32 field is five bytes on the wire no matter what it holds, tag plus four, and a fixed64 field is nine. A varint of the same value is two bytes when the number is small and grows only as the number gets bigger. I measured the crossover: a uint32 value of 268435455, just under 2 to the 28, still fits in five bytes total, and 268435456 jumps to six, so below that line fixed is always the bigger encoding. For the 64-bit pair the crossover sits at 2 to the 49, where the varint reaches nine bytes and ties fixed64, and past 2 to the 56 the varint is ten bytes and fixed64 is the smaller one. So the honest answer to why would anyone use fixed is: you would not, for size, unless your values live at 2 to the 49 and up or your layout needs a constant stride. And zero is where the encoders disagree. An absent fixed32 is not on the wire in either, but an explicit zero is: protoc 25.3 given a set to zero writes nothing, while the JS library writes the tag plus four zero bytes, 0d00000000, same present-but-empty rule it applies to empty strings and empty Any. Both decode back to zero, so the wire still interoperates, but a byte count or a diff will see five bytes in one and zero in the other for a field both claim is zero.

Within a family the swap is silent, which is the version of this that survives in production. The float 1.5 is the IEEE 754 single bits 0x3fc00000, which sit on the wire as 00 00 c0 3f, and a schema that calls that field a fixed32 decodes the same bytes to 1069547520 in both decoders, a fine integer, no error. At the 64-bit end the same double 1.5 bytes under a fixed64 schema decode to 4609434218613702656 in JavaScript, and the C++ decoder prints the same bits in hex, 0x3ff8000000000000, which is the same number. And a fixed64 holding 1, read as a double, is 5e-324 in the JS library and 4.94065645841247e-324 in the C++ one, the same denormal to different print precision. These are the values a fleet can actually ship, because a field retyped between float and fixed32, or double and fixed64, is a same-wire-type change, and the diff tab that ships with the converter classifies it exactly that way: old bytes still decode, but the values are reinterpreted. The retype to a different wire family is the loud one, and the fixed types are where the loud boundary sits closest, one byte width away from a working read.

The encode side is where the fixed types are also the quietest. The JS library does not range-check a fixed32 on the way in: hand it 2 to the 32 and it wraps to zero, hand it minus one and it wraps to 4294967295, both with no error, because the generated code is an unsigned shift of the value. The float field is the same family of silence with a different shape: a 0.1 goes out the door as the nearest single, and comes back as 0.10000000149011612, which is the correct behavior of a 32-bit mantissa, not a bug, but it is a value your tests did not send. A 1e20 through a float field loses about two trillion on the way back. And a NaN becomes the four bytes 00 00 c0 7f, written by both libraries, and the JSON mapping prints it as the string NaN, which is the only non-finite value that survives a round trip at all. None of this errors, because none of it is wrong, which is why it is worth knowing the boundary before it is worth diagnosing.

The JSON side of the mapping keeps the split clean, mostly. A fixed32 comes out as a plain number, exactly like a uint32, and a fixed64 comes out as a decimal string, exactly like the other 64-bit integers, because the JSON mapping post that covers int64 applies to fixed64 without modification. The JSON has no wire type in it, so a 7 is a 7 whether the schema says uint32 or fixed32, and the JSON mapping cannot be the tool that tells the two apart. The raw decode tab is the one place every reading sits side by side: for a four-byte field it prints the unsigned integer, the signed integer, and the float, and for eight bytes the 64-bit integer pair and the double, so the reinterpretations above are visible at a glance instead of having to be encoded and decoded one pair at a time. The converter with the parser this post measured is at [proto.datajutsu.com](https://proto.datajutsu.com/?ref=datajutsu.com), and the tag structure it is walking is in the [wire format post](https://datajutsu.com/how-protobuf-wire-format-works/).