LEB128 (ULEB + SLEB)

Client

LEB128 encodes integers in 7-bit groups with a continuation bit—little-endian. ULEB (unsigned) is for non-negative values; SLEB (signed) uses two’s-complement and sign extension on the last chunk (same model as WebAssembly and LLVM SLEB). Use decimal lines to encode, or a hex/byte bytestream to decode a sequence of LEBs.

Part of encoding tools; raw bytes: hex.

Workspace

Match ULEB vs SLEB to your format; decodes the whole buffer as a chain of LEBs.

LEB type:|Decode as:

LEB128 (ULEB + SLEB)

?

ULEB = non-negative; SLEB = two’s-complement, same wire style as WebAssembly / LLVM. Encode one integer per line(optional # comment on each line); multiple lines also show a concatenated stream.

Decoding reads consecutive LEBs from the stream until the buffer ends—same as a varint or WASM opcode operand sequence.

Common use cases

  • Check wasm opcode or DWARF LEB fields against a known decimal, or the reverse, without leaving the tab.
  • Inspect concatenated LEBs the same way a byte parser would, one value per drain of the LEB state machine.
  • Use ULEB for non-negative only; switch to SLEB for signed, two’s-complement wire form.

Common mistakes to avoid

  • Mixing ULEB and SLEB on the same bytes

    The unsigned and signed encodings of the same bit pattern are different. Pick the mode that matches the producer (WASM, proto3 varint, etc.).

  • Assuming 32-bit wrap

    This tool uses BigInt; values can be larger than 2^32 minus one when the byte length allows a legal LEB.

  • Odd-length hex by accident

    Hex decode expects full bytes (two nybbles per byte). For odd-length paste, add a leading zero to the first byte only if you really mean a half byte.

FAQ

Is this exactly WebAssembly or Protobuf varint?

ULEB and SLEB follow the same little-endian, 7-bit-hunk LEB family used in WASM and in many binary formats. Protobuf’s varint is unsigned; always pick ULEB for those unless your docs call for signed (SLEB).

What is the 624485 example?

It is a common ULEB-32 test vector: decimal 624485 encodes to three bytes e5 8e 26 (shown here as e58e26 in hex with no 0x).

Is data sent to a server?

No. All work happens locally in the page.

Common search terms

Phrases people search for that match this tool. See the full long-tail keyword index.

  • leb128 encode decode online
  • uleb128 sleb128 wasm varint
  • protobuf leb little endian base 128
  • dwarf uleb128 decode

Related utilities you can open in another tab—mostly client-side.