VarInt Encoder

Encodes a Vn integer as a VarInt. VarInt is an efficient way of encoding variable length integers and is commonly used with Protobuf.

Input: TextResult: Binary bytes

Text input

Run to see the result

Examples

A small field value

Input

1

Expected answer

Hexadecimal bytes
OffsetHex bytesASCII
0000000001.
A 7-bit boundary

Input

127

Expected answer

UTF-8 text · exact bytes

The first two-byte value

Input

128

Expected answer

Hexadecimal bytes
OffsetHex bytesASCII
0000000080 01..
The official Protobuf example

Input

150

Expected answer

Hexadecimal bytes
OffsetHex bytesASCII
0000000096 01..
A counter of 300

Input

300

Expected answer

Hexadecimal bytes
OffsetHex bytesASCII
00000000ac 02..
A three-byte boundary

Input

16384

Expected answer

Hexadecimal bytes
OffsetHex bytesASCII
0000000080 80 01...

Format reference: VarInt Encode background and specification

Related tools

Browse networking tools