Base32 Encoder & Decoder

Convert text to Base32 format or decode Base32 encoded strings back to plain text

Invalid Base32 string. Please check your input.
Copied!

What is Base32 Encoding?

Base32 is a notation for encoding arbitrary byte data using a 32-character set that's designed to be more human-readable than Base64. It uses the 26 uppercase letters A-Z and the digits 2-7 (excluding 0, 1, 8, and 9 to avoid confusion with similar-looking letters).

Why Use Base32?

  • Human Readability: More readable than Base64 since it avoids characters that look alike
  • Case Insensitivity: Standard Base32 is uppercase only, reducing errors in manual transcription
  • URL Safety: All Base32 characters are safe for URLs without encoding
  • TOTP Authentication: Used in two-factor authentication systems and apps
  • DNS Names: Base32 is used in various DNS naming schemes

Base32 Alphabet

The standard Base32 alphabet uses these characters:

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 2 3 4 5 6 7

Base32 vs Base64

While Base64 is more space-efficient (encoding 3 bytes into 4 characters), Base32 is more human-friendly (encoding 5 bytes into 8 characters). Base32 is preferred when humans need to manually read and enter the encoded data, such as security codes or recovery keys.

Understanding Base32 Encoding and Decoding

Base32 encoding is a binary-to-text encoding scheme that represents binary data with a set of 32 different printable characters. It's particularly useful for applications where human readability and error resistance are important factors.

How Base32 Encoding Works

Base32 encoding converts binary data into a limited character set, making it safe for protocols that only support a subset of ASCII characters. The process involves several specific steps:

  1. Divide the input data into 5-byte (40-bit) groups
  2. Split each 40-bit group into eight 5-bit chunks
  3. Convert each 5-bit value (0-31) to the corresponding Base32 character
  4. If the final group has fewer than 5 bytes, pad with '=' signs as needed

The Base32 Encoding Process

Input bytes:    | Byte 1 | Byte 2 | Byte 3 | Byte 4 | Byte 5 |
                |76543210|76543210|76543210|76543210|76543210|
                +--------+--------+--------+--------+--------+
                |              40 bits of input               |
                +--------+--------+--------+--------+--------+
                |43210|43210|43210|43210|43210|43210|43210|43210|
Output chars:   |  A  |  B  |  C  |  D  |  E  |  F  |  G  |  H  |

Encoding 5 bytes into 8 Base32 characters

Padding in Base32

When the input data's length isn't a multiple of 5 bytes, padding is added to ensure the output follows the Base32 format rules. The number of padding characters ('=') depends on how many bytes are in the final incomplete group:

Input Bytes in Final Group Output Characters Padding Characters
1 byte (8 bits) 2 chars 6 padding chars (======)
2 bytes (16 bits) 4 chars 4 padding chars (====)
3 bytes (24 bits) 5 chars 3 padding chars (===)
4 bytes (32 bits) 7 chars 1 padding char (=)
5 bytes (40 bits) 8 chars No padding

Common Applications of Base32

Two-Factor Authentication (TOTP)

Google Authenticator and other TOTP apps use Base32 for encoding shared secrets. The Base32 format makes it easier for users to manually enter these keys when setting up a new device.

Backup and Recovery Codes

Many services provide backup codes in Base32 format for account recovery purposes, as they're easier to transcribe correctly than Base64 or hex.

Tor .onion Addresses

Tor hidden service addresses use a modified form of Base32 encoding to generate their .onion domain names.

File Systems

Some file systems use Base32 for representing file names or identifiers that need to be case-insensitive but still readable.

Base32 Variants

Several variations of Base32 exist for specific use cases:

  • Base32hex: Uses the digits 0-9 and letters A-V, making it more suitable for hexadecimal-familiar users
  • z-base-32: Designed to use easier-to-distinguish characters for human recognition
  • Crockford's Base32: Uses carefully chosen characters to minimize transcription errors
  • Base32 for Geohashing: A specialized variant used in geohashing coordinates

Base32 vs Base64 Size Comparison

Base32 encoding increases the data size by about 60% (5 bytes → 8 characters), while Base64 increases it by about 33% (3 bytes → 4 characters). The tradeoff is readability and error resistance versus compactness.

Conclusion

Base32 encoding provides a good balance between data density and human readability. While not as compact as Base64, it offers benefits in specific scenarios where manual transcription is common, or where case-insensitivity and URL safety are important. Understanding when to use Base32 instead of other encoding schemes is a valuable skill for developers working on systems where human interaction with encoded data is necessary.