Varint Encoder Decoder
Encode and decode unsigned protobuf-style variable-length integers to and from hex bytes in your browser.
Protobuf-Style Varint Encoding
Variable-length integers (varints) encode unsigned integers using 7 data bits per byte and a continuation bit. They appear throughout Protocol Buffers, gRPC, and other compact binary schemas. Smaller values use fewer bytes, which saves space in logs and on the wire.
Encode a decimal value to see its varint hex bytes, or paste hex to recover the integer. The decoder reads consecutive varints when multiple values are present in one buffer. For related binary work, use CBOR MessagePack Converter or Base64 Encoder.
Encoding Rules
Each output byte stores 7 bits of the value in little-endian bit order within the varint. If more bits remain, the high bit is set to 1; the final byte clears that bit. For example, decimal 300 encodes to bytes ac 02 because $300 = 0x12c$ splits into continuation groups.
Frequently Asked Questions
Are negative numbers supported?
Standard protobuf varints are unsigned. Signed types use zig-zag encoding, which is not covered here.
What is the maximum value?
Encoding supports 64-bit unsigned integers (up to $2^{64}-1$).
Can I decode multiple varints at once?
Yes. Paste a longer hex string and the tool decodes each varint sequentially, one per line in the output.
Is this the same as UTF-8?
No. UTF-8 encodes Unicode text. Varints encode integers with a different bit grouping scheme.