> ## 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 Negative Int Is Ten Bytes on the Wire (and a String, Not a Number, in the JSON)
- URL: https://datajutsu.com/protobuf-negative-int-json/
- Published: 2026-10-30T12:21:16.000Z
- Updated: 2026-10-30T12:21:16.000Z
- Author: Data Jutsu

Negative numbers in protobuf are the one place where the sign of a value costs you bytes, and it costs a lot. A minus one written into an int32 is not a small number on the wire; it is ten bytes of value, and the same is true in an int64\. I measured the full ladder, what the tool at proto.datajutsu.com prints when a negative comes back through the decode tab, and what happens when you re-read one producer's negative bytes under a different signedness. The short version: sign is expensive on the wire, the JSON output splits on declared width rather than on sign, and the silent failure is a minus one that your schema re-reads as four billion two hundred ninety four million.

The sign is expensive because the varint is written in little endian two's complement. A negative 32-bit value widens to the full sixty four bit two's complement the moment the encoder writes it, so an int32 minus one and an int64 minus one sign out as the same ten payload bytes after the tag, ffff ffff ffff ffff 01 in the order they hit the stream. I encoded the ladder and watched it. int64 minus five came out as the ten bytes fb ff ff ff ff ff ff ff ff 01, with the top byte, the one that actually makes the value negative, sitting last. The minimum int64, minus two to the sixty third, is eight ff bytes and then 01\. It is the same wire format the [wire format post](https://datajutsu.com/how-protobuf-wire-format-works/?ref=datajutsu.com) covers on the positive side, where small numbers stay small; here it is the sign, not the magnitude, that forces the full width.

The bytes do not carry a sign the way a human would expect. They carry a sixty four bit pattern, and it is the schema that decides whether to read that pattern as signed or unsigned. I took the ten bytes a producer wrote for an int32 minus one and pointed a decoder at them twice. Under a uint32 field the same ten bytes read back as 4294967295\. Under a uint64 field they read back as 18446744073709551615, which is two to the sixty fourth minus one, the maximum unsigned value. No error, no warning, just the value you did not ask for. The sibling story, where those same ten bytes read as a sint32 land on the minimum 32-bit integer, is covered in the [sint zigzag post](https://datajutsu.com/protobuf-sint32-zigzag/?ref=datajutsu.com); this one is the same trick on the unsigned side of the fence.

This is the part that surprises people who expect the JSON to mirror the number. In the tool's decode tab, a negative 64-bit integer comes back as a string, and a negative 32-bit integer comes back as a bare number. I encoded an int64 minus five and decoded it under the tab's own options, and the field printed the string -5\. I did the same for an int32 minus three, and it printed the number -3\. The boundary is not the sign and it is not the magnitude; it is the declared width. Sixty four bit fields, signed or unsigned, are mapped to decimal strings, and 32-bit fields stay numbers, which is exactly what the [JSON mapping post](https://datajutsu.com/protobuf-json-mapping/?ref=datajutsu.com) says it will do. The sign of the value changes nothing about the type; a positive int64 and a negative int64 are both strings.

With the long.js build the tool ships loaded before the engine, those strings are exact all the way to the edges. I round tripped the minimum int64 and it came back as the string -9223372036854775808, not a rounded double. Two to the fifty third plus one came back as 9007199254740993, exact, which is the number the no-Long baseline used to round down by one and is the failure the [int64 precision post](https://datajutsu.com/protobuf-int64-precision-boundary/?ref=datajutsu.com) documents. The string or number split is about the declared type, so it leaks into the defaults the tab invents for fields that were never sent. An unset int64 filled in by the defaults option is the string zero, while an unset int32 is the number zero. The two look different inside the same object, and that difference is the width, not presence.

So the rules that fall out of this: the sign of a value costs bytes on the wire and does not change the type of its JSON, a negative is at least ten payload bytes in either a 32-bit or a 64-bit signed field because the encoder widens to sixty four bit two's complement, and the silent failure sits on the reader, where the same ten bytes are one producer's minus one and your schema's four billion two hundred ninety four million if you declared the field unsigned. You can watch all of it against your own bytes in the [tool at proto.datajutsu.com](https://proto.datajutsu.com/?ref=datajutsu.com): paste the hex and watch the same field print as a string when it is sixty four bits wide and as a number when it is not. The [silent loss post](https://datajutsu.com/protobuf-silent-loss-both-directions/?ref=datajutsu.com) covers the values that vanish in the other direction; this is the value that survives the trip and comes home wearing a different sign.