basE91 Encoder / Decoder
Compact basE91 binary-to-text encoding (~14% denser than Base64).
Overview
The basE91 encoder packs binary data into printable ASCII more tightly than Base64 or Ascii85, achieving roughly a 14% size advantage over Base64 with no padding character. Paste bytes, hex, or text and get back a dense token; paste basE91 and it round-trips back to the original bytes.
It is a niche but useful encoding for embedding binary payloads in QR codes, SMS messages, or hand-written tokens where every character counts. Researchers comparing binary-to-text density and developers writing space-constrained CLI tools will appreciate this basE91 encoder online.
How it works
basE91 (Henke, 2005) uses an alphabet of 91 printable ASCII characters — A-Z, a-z, 0-9, and a curated set of symbols that survive most JSON and URL contexts. Encoding repeatedly pulls bits from the input stream into an accumulator and emits a pair of base-91 digits whenever the accumulator holds enough bits (13 or 14, depending on the high digit). Because 2 × 91 ≈ 2^13.5, each pair of output characters carries about 13.27 bits of input, beating Base64's 12 bits per 2 characters. Decoding mirrors the process: each digit pair is converted back to bits and shifted out as bytes.
Examples
Input: test
Output: fPNKd
Input: Hello, World!
Output: >OwJh>}AQ;r@@Y?F
Input: "" (empty)
Output: ""
Input: fPNKd
Output: test
FAQ
Is it standardised?
No. basE91 is a reference implementation by Joachim Henke; there is no RFC. Most ports follow the original C source closely, but check before mixing libraries.
When would I pick basE91 over Base85?
When you need maximum density and your transport tolerates the extra punctuation characters. basE91 uses 91 characters versus Ascii85's 85, packing more bits per character at the cost of a slightly larger alphabet.
Are the output characters URL-safe?
Mostly, but not entirely — characters like ", &, and + may require URL-encoding depending on context. For URL slugs, prefer Base62 or Base64URL.
Is it suitable for cryptographic keys?
It is just an encoding, so yes — but the security comes from the key material itself, not from being basE91-encoded. The compact form is convenient for keys you have to type by hand.