LEB128 Encoder And Decoder

Encode UTF-8 text as unsigned LEB128 hex, or decode unsigned LEB128 hex back into text.



Question

What is LEB128?

LEB128, or Little Endian Base 128, is a variable-length integer encoding that stores an integer in one or more bytes. Each byte contributes seven data bits, and the high bit indicates whether another byte follows. Because the least significant seven-bit group is written first, small unsigned values fit in one byte while larger values expand only as needed.

This tool works with the unsigned LEB128 form. When you click Encode text, the page converts the input string to UTF-8 bytes, treats those bytes as one little-endian unsigned integer, and returns that integer as a continuous lowercase LEB128 hexadecimal byte string. When you click Decode LEB128, the page expects hexadecimal bytes with optional spaces, commas, or 0x prefixes, decodes one unsigned LEB128 value, converts the resulting little-endian bytes back to UTF-8, and writes the decoded text.

Use it when you need to inspect a text-to-ULEB128 byte sequence, compare unsigned LEB128 values, or understand how a text payload changes when represented as a little-endian integer before LEB128 encoding. For example, standard unsigned LEB128 encodes the integer 624485 as e5 8e 26; this page applies the same unsigned byte rules after first turning text into UTF-8 bytes.

LEB128 is used by formats such as DWARF debugging information and the WebAssembly binary format, but those formats usually encode numeric fields with defined widths and signedness. This page is not a general WebAssembly or DWARF editor, and it does not decode signed LEB128 values, multiple concatenated values, schema-aware fields, or arbitrary binary records.

Decoding depends on the input being a complete unsigned LEB128 byte sequence that represents valid UTF-8 text after conversion back to little-endian bytes. Very large values can be expensive to process in a browser, and malformed hex or incomplete continuation bytes will produce an error instead of output.


Books

References