Introduction
Looking for a binary-to-text encoding that is more efficient than Base64 or Base85? Base91 uses a 91-character alphabet to encode binary data into printable ASCII, achieving approximately 81% efficiency compared to Base64's 75%. This means smaller output strings for the same input data. The algorithm was designed by Joachim Henke and is particularly useful when encoding size matters more than compatibility. Paste your text below to encode or decode Base91 data.
What this tool does
- Encodes text or binary data into Base91 format using a 91-character printable ASCII alphabet.
- Decodes Base91 strings back to the original text or binary data.
- Achieves approximately 81% encoding efficiency, compared to 75% for Base64 and 80% for Base85.
- Uses the base91 npm package, which works in both Node.js and browsers.
- Handles arbitrary binary data through UTF-8 encoding.
- Processes all data locally in your browser with no server communication.
How this tool works
In Encode mode, paste your text and the tool encodes it to a Base91 string. The tool converts the input text to bytes using UTF-8 encoding, then applies the Base91 encoding algorithm. In Decode mode, paste a Base91 string and the tool decodes it back to the original text. The Swap button toggles between encode and decode modes and moves the output into the input field. Invalid Base91 characters are silently ignored during decoding.
How Base91 encoding works
Base91 was designed by Joachim Henke and is described on the basE91 website. The algorithm uses a 91-character alphabet to encode binary data more efficiently than Base64. The key insight is that 13 bits of binary data can be encoded into 2 characters of the Base91 alphabet (91^2 = 8281, which is greater than 2^13 = 8192). This gives a theoretical efficiency of 13/16 = 81.25%, compared to Base64's 6/8 = 75% (where 6 bits are encoded per character). The Base91 alphabet consists of printable ASCII characters excluding the hyphen (-) and backslash (\), which can cause issues in certain contexts. The full alphabet is: `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@]^_`{|}~"`. The encoding process reads the input as a bit stream, groups bits into 13-bit chunks, and maps each chunk to two characters from the alphabet. A remaining partial chunk at the end is handled specially. The decoding process reverses this: pairs of characters are converted back to 13-bit values, and the bit stream is reassembled. Base91 is not standardized by any RFC. It is a niche encoding used in applications where encoding efficiency matters more than universal compatibility. Unlike Base64, which is defined in [RFC 4648 and supported by virtually every programming language, Base91 has limited library support. The base91 npm package used by this tool was created by Brian White (mscdex) and works in both Node.js and browsers. Base91 output is not URL-safe without additional encoding, as it contains characters like `!`, `#`, `$`, `%`, `&`, `?`, and `"` that have special meanings in URLs.
How to use this tool
- Select Encode or Decode mode using the buttons in the settings panel.
- In Encode mode, paste the text you want to encode. The tool outputs a Base91 string.
- In Decode mode, paste a Base91 string. The tool outputs the decoded text.
- Use the Copy result button to copy the output to your clipboard.
- Use the Swap button to toggle between encoding and decoding.
Real-world examples
Encoding a short string
Input: 'Hello World!'. The Base91 output is '>OwJh>Io0Tv!8PE'. Compare this to Base64 ('SGVsbG8gV29ybGQh'), which is 16 characters. Base91 produces 15 characters for the same input, demonstrating its efficiency advantage.
Encoding binary-like data
Input: A string with many special characters like 'test\x00\x01\x02data'. Base91 encodes arbitrary byte sequences, making it suitable for encoding binary data that needs to be transmitted through text-only channels.
Decoding a Base91 string
Input: '>OwJh>Io0Tv!8PE'. Switch to Decode mode and paste the Base91 string. The tool decodes it back to 'Hello World!'. Invalid characters in the input are ignored, so partially corrupted strings may still produce readable output.
Comparison with similar methods
| Method | Complexity | Typical use |
|---|---|---|
| Base91 | 13-bit to 2-char mapping, ~81% efficiency | Compact binary-to-text encoding |
| Base64 (RFC 4648) | 6-bit to 1-char mapping, 75% efficiency | Email attachments, data URIs, JWTs |
| Base85 (Ascii85) | 4 bytes to 5 chars, 80% efficiency | PDF encoding, PostScript |
| Base32 (RFC 4648) | 5-bit to 1-char mapping, 62.5% efficiency | Case-insensitive encoding, DNS |
Limitations or considerations
Base91 is not standardized by any RFC and has limited library support compared to Base64. It is not URL-safe without additional encoding, as the alphabet contains characters that have special meanings in URLs. The encoding is not widely recognized by email systems, web APIs, or data URI schemes. Base91's efficiency advantage over Base64 is modest (81% vs 75%), so the lack of compatibility may outweigh the size savings for most applications. The tool encodes text as UTF-8 before applying Base91, so decoding non-UTF-8 binary data may produce unexpected results. For production use, consider Base64 for maximum compatibility or Base85 for PDF-related applications.
Frequently asked questions
Why would I use Base91 instead of Base64?
Base91 produces shorter output strings (approximately 81% efficiency vs 75% for Base64). This is useful when encoding size matters, such as in QR codes, SMS messages, or compact data storage. However, Base64 has universal compatibility and is standardized in RFC 4648, while Base91 has limited library support.
Is Base91 URL-safe?
No. The Base91 alphabet includes characters like `!`, `#`, `$`, `%`, `&`, `?`, and `"` that have special meanings in URLs. If you need URL-safe output, use Base64 with URL-safe alphabet (- and _ instead of + and /), or apply URL encoding to the Base91 output.
What characters does Base91 use?
Base91 uses 91 printable ASCII characters: all letters (upper and lower), digits, and most punctuation. It excludes the hyphen (-) and backslash (\) to avoid issues in file names and paths. The full alphabet is `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~"`.
Can Base91 encode binary data, not just text?
Yes. Base91 operates on raw bytes, not characters. This tool converts input text to bytes using UTF-8 encoding before applying Base91. For arbitrary binary data (like images or compressed files), you would need to pass the raw bytes to the base91 library directly.
Conclusion
Base91 provides a compact alternative to Base64 for binary-to-text encoding, achieving 81% efficiency through its 91-character alphabet. This tool handles encoding and decoding in your browser using the base91 npm package. For most production applications, Base64 remains the better choice due to universal compatibility. Check out the related Base32, Base58, Base62, Base64, and Base85 encoder tools on this site for comparison.