Skip to content
100% local

LEB128 encoder

Encode integers to variable-length LEB128 bytes and decode them back, signed or unsigned.

Input
Output

LEB128 encoder

LEB128 ("Little Endian Base 128") is the variable-length integer format behind DWARF debug info, WebAssembly modules and Protocol Buffers. Small values take one byte; larger ones spill into more, seven bits at a time, with the top bit of each byte marking "more bytes follow." This tool encodes a list of integers into a LEB128 byte stream, or decodes a stream back into the integers behind it — paste one integer per line to encode, or a run of bytes to decode.

Turn on Signed (SLEB128) for negative numbers, via the sign-extended variant; leave it off for unsigned (ULEB128), which rejects negative input instead of guessing. Output byte format sets how encoded bytes are written — hex digits, decimal values, or raw characters, one per byte — and Input byte format tells the decoder which shape to expect. Keep zero padding pads every byte to a fixed width for a tidy result; turn it off for the shortest text. Wrap output breaks a long line into fixed-width rows for readability, without touching the underlying bytes.

Integers on separate lines are encoded back-to-back into one continuous stream with no separators, exactly as LEB128 is used in real binary formats — the continuation bit alone marks each value's boundary. Decoding reverses that, printing one integer per output line. A stream ending mid-value, a value running past ten bytes, a non-numeric line, a negative number in unsigned mode, or a character your chosen format can't hold each stop with a specific error rather than a silently wrong answer.

Everything runs locally in your browser — no integer or byte ever leaves your device. Copy the result, download it as a .txt file, or send the output back into the input to chain an encode into a decode, or the reverse.

FAQ

What is the difference between ULEB128 and SLEB128?
ULEB128 (unsigned) only represents non-negative integers and is slightly more compact. SLEB128 (signed) uses one extra bit per value to sign-extend correctly, so it can represent negative numbers too. Turn on the Signed option to switch.
Why are multiple encoded integers run together with no separator?
That's how LEB128 is actually used in binary formats: the continuation bit on each byte tells a decoder exactly where one value ends and the next begins, so no delimiter is needed. Decoding splits the stream back into separate integers automatically.
What does the padding option change?
With padding on, hex bytes are always written as two digits and decimal bytes as three, so columns line up. With it off, each byte is written as compactly as possible. It only affects display — the encoded value is identical either way.
Why did I get an error instead of a result?
The tool validates every line or byte before producing output: a line that isn't a whole number, a negative value while Signed is off, an out-of-range byte, or a byte stream that ends before a value is complete all stop with a message naming exactly what's wrong and where.
Is my data uploaded anywhere?
No. Encoding and decoding both run entirely in your browser — nothing you paste here is ever sent to a server.