What Is Base32 Encoding?
Base32 is a binary-to-text encoding scheme defined in RFC 4648 Section 6. It uses 32 characters (A-Z, 2-7) to represent binary data. Each character encodes 5 bits of information. Base32 produces output approximately 60% larger than the original binary data, compared to the 33% overhead of Base64 encoding.
The 32-character alphabet was chosen to exclude digits 0, 1, 8, and 9, which can be confused with the letters O, I, B, and g. This deliberate omission makes Base32 more suitable for contexts where humans read, type, or verbally communicate encoded strings. The encoding process groups input bits into 5-bit segments, maps each segment to a character, and adds = padding to make the output length a multiple of 8 characters.
How Does Base32 Differ from Base64?
Base32 and Base64 are both binary-to-text encodings defined in the same RFC, but they differ in alphabet size, efficiency, and intended use cases. Base64 is more compact, while Base32 is more readable and case-insensitive.
| Property | Base32 | Base64 |
|---|---|---|
| Characters | A-Z, 2-7 (32) | A-Z, a-z, 0-9, +, / (64) |
| Bits per character | 5 | 6 |
| Size overhead | 60% | 33% |
| Case sensitive | No | Yes |
| Padding | = (multiple of 8) | = (multiple of 4) |
| RFC section | RFC 4648 §6 | RFC 4648 §4 |
| Human readable | More readable | Less readable |
| URL safe | Yes (no special chars) | No (contains +, /) |
For standard Base64 encoding and decoding, use the Base64 text encoder or Base64 text decoder. To understand the full Base64 character table, including index-to-character mappings, see the character reference page.
When Should You Use Base32 Instead of Base64?
Use Base32 when case-insensitivity is a requirement, such as DNS domain names, TOTP authenticator secret keys, or environments where uppercase and lowercase letters are treated identically. Base32 is also preferred when humans need to transcribe encoded data manually, because its alphabet avoids visually ambiguous characters like O/0 and I/1.
TOTP (Time-based One-Time Password) applications such as Google Authenticator and Authy use Base32 to encode shared secret keys. When a user scans a QR code or manually enters a setup key, that key is a Base32 string. The case-insensitivity of Base32 reduces transcription errors when users type the key manually. For contexts where compactness matters more than readability, Base64 remains the better choice.
How Does Base32 Encoding Work?
The Base32 algorithm processes input bytes by converting them to a continuous binary string, splitting that string into 5-bit groups, and mapping each group to a character from the A-Z2-7 alphabet. The output is padded with = characters to reach a multiple of 8 characters.
Step-by-step example encoding "Hi":
| Step | Data | Value |
|---|---|---|
| Input characters | H, i | 2 ASCII characters |
| Decimal values | 72, 105 | 2 bytes |
| Binary (8-bit each) | 01001000 01101001 | 16 bits |
| Pad to multiple of 5 | 01001000 01101001 0000 | 20 bits (4 zeros added) |
| Split into 5-bit groups | 01001 00001 10100 10000 | 4 groups |
| Decimal index values | 9, 1, 20, 16 | 4 indices (0-31) |
| Base32 characters | J, B, U, Q | 4 output characters |
| With padding | JBUQ==== (padded to 8 characters) | |
The 2-byte input "Hi" produces the 8-character output "JBUQ====". The 4 padding characters indicate that only 2 of the 5 possible input bytes in this 8-character block contained data. For a detailed breakdown of the Base64 equivalent of this process, see the Base64 algorithm explanation.
What Are the Variants of Base32?
Several Base32 variants exist, each using a different character alphabet for specific purposes. The standard RFC 4648 alphabet is most common, but alternatives address different requirements for character selection.
| Variant | Alphabet | Use Case |
|---|---|---|
| Base32 (RFC 4648) | A-Z, 2-7 | General purpose, TOTP secrets |
| Base32hex (RFC 4648) | 0-9, A-V | Preserves sort order of encoded data |
| Crockford's Base32 | 0-9, A-Z (no I, L, O, U) | Check symbols, human-friendly identifiers |
| z-base-32 | Custom 32-char set | Optimized for human readability |
Crockford's Base32 excludes the letters I, L, O, and U to prevent confusion with 1, 1, 0, and V respectively. It also supports optional check digits for error detection. The Base64 hex converter can help compare encoded outputs across different base systems. For URL-safe encoding needs, see the URL-safe Base64 encoder.
Frequently Asked Questions
What is the Base32 alphabet?
The Base32 alphabet consists of the 26 uppercase letters A through Z and the 6 digits 2 through 7, totaling 32 characters. This alphabet is defined in RFC 4648 Section 6. The digits 0 and 1 are excluded to avoid confusion with the letters O and I.
Why is Base32 less efficient than Base64?
Base32 encodes 5 bits per character, while Base64 encodes 6 bits per character. This means Base32 requires 8 output characters for every 5 input bytes (60% overhead), whereas Base64 requires only 4 output characters for every 3 input bytes (33% overhead). The smaller alphabet trades storage efficiency for case-insensitivity and readability.
Is Base32 case-sensitive?
No, Base32 is not case-sensitive. The standard alphabet uses only uppercase letters A-Z and digits 2-7. Decoders typically accept both uppercase and lowercase input, treating them identically. This case-insensitivity is one of the primary advantages of Base32 over Base64.
Where is Base32 commonly used?
Base32 is commonly used for TOTP authenticator secrets in apps like Google Authenticator and Authy, DNS domain name encoding, file names on case-insensitive file systems, and any context where human transcription of encoded data is required.
Can Base32 encode binary files?
Yes, Base32 can encode any binary data including files, images, and executables. However, the 60% size increase makes it less practical than Base64 for large files. Base32 is typically reserved for short strings where case-insensitivity or human readability is more important than compactness. For encoding files with Base64, use the Base64 image encoder.