Base91 Encode & Decode
What is Base91?
Base91 is a binary-to-text encoding scheme that represents binary data using 91 printable ASCII characters. It's more efficient than Base64, typically achieving about a 23% reduction in output length. The encoding uses characters from '!' to '~' (ASCII 33-126), excluding the backslash character.
How It Works
Encoding: Input binary data is processed in 13-bit groups. Each group is converted to two Base91 characters using a lookup table. The encoding is more efficient than Base64 because it uses more characters (91 vs 64) and optimizes the bit-to-character mapping.
Decoding: The encoded string is processed in pairs of characters, converting each pair back to a 13-bit value. These values are then concatenated and split into bytes to reconstruct the original binary data.
- Uses 91 characters: '!' through '~' (ASCII 33-126), excluding '\'.
- Case-sensitive.
- More efficient than Base64 (approx. 23% shorter output).
- No special delimiters needed.
- Whitespace within the encoded data is ignored during decoding.
Use Cases
Base91 is particularly useful when space efficiency is important:
- URL Shorteners: Used to encode long URLs into shorter strings.
- Binary Data Transfer: When you need to transfer binary data in a text format with minimal overhead.
- Storage Optimization: When you need to store binary data in a text format with minimal space usage.
Why Use Base91?
The main advantage of Base91 is its efficiency compared to Base64:
- Efficiency: Offers lower data expansion (overhead) than Base64.
- Printable Characters: Uses only printable ASCII characters, suitable for text streams.
Disadvantages include slightly more complex implementation than Base64 and the use of characters that might need escaping in some contexts (like URLs).
How to Use This Tool
- Select either "Encode" or "Decode" mode.
- Enter the text (UTF-8 for encoding) or Base91 string (for decoding) into the top input field.
- The result will appear automatically in the bottom output field.
- Use the swap button to switch the input and output, automatically changing the mode.
- Click the copy icon next to the output label to copy the result.
- Error messages will appear for invalid input characters or if the decoded data is not valid UTF-8.