Base91 Encoder/Decoder

Encode binary data with the efficient Base91 alphabet

Ad placeholder (leaderboard)

What basE91 does

basE91 (sometimes written Base91) encodes arbitrary bytes into a string of printable ASCII characters so binary data can travel safely through text-only channels. Its appeal over Base64 is efficiency: it carries more information per output character, so encoded payloads are noticeably shorter.

How it works

The encoder treats the input as a stream of bits and reads them into a bit buffer. Whenever the buffer holds enough bits it pulls a value of either 13 or 14 bits — choosing 14 bits when the low 13 bits would exceed 88, which keeps every value below 8281 (that is 91 * 91). Each value is then written as two characters: the low digit is value mod 91 and the high digit is value / 91, both indexed into the 91-character alphabet.

v = buffer & 0x1FFF        // try 13 bits
if v > 88:  shift out 13 bits
else:       v = buffer & 0x3FFF, shift out 14 bits
emit alphabet[v % 91], alphabet[v / 91]

Decoding reverses this: characters are read in pairs, recombined as low + high * 91, and the bits are streamed back out as bytes.

Tips and notes

basE91 is ideal when you need binary-safe text but want less bloat than Base64 — for instance embedding small blobs in JSON or source files. Because the alphabet avoids the backslash and dash, the output rarely needs further escaping. Remember that decoding yields raw bytes; this tool then interprets them as UTF-8, so feeding it the output of a non-text binary will produce a decode error rather than readable text.

Ad placeholder (rectangle)