Protocol Buffer Varint Encoder

Enter an unsigned integer to encode it as a protobuf varint.

How to use

  1. Enter your values in the fields above.
  2. Press Calculate to see your result instantly.
  3. Use the Share button to copy a link to your result.

About this calculator

Protocol Buffers, Google's binary serialization format, encodes integers using base-128 varints to save space on small numbers: each byte carries 7 bits of the value plus a "continuation" bit (the most significant bit) that's set to 1 if more bytes follow and 0 on the final byte. This means small integers — the overwhelming majority in real-world protobuf messages, like field lengths, enum values and IDs — encode in just one byte instead of the four or eight a fixed-width integer would always cost, which is the whole reason protobuf messages stay so compact on the wire.

This calculator takes an unsigned integer and encodes it into its varint byte sequence, showing each byte in both hex and binary so you can see the continuation bits at work. Backend engineers debugging a protobuf wire-format issue, developers writing a custom protobuf parser or serializer without a generated library, and students learning binary encoding schemes use it to manually verify that a value's byte encoding matches what their code produces or expects.

Was this helpful?

Comments (0)

  • Be the first to comment.

Popular calculators

All Calculators