Encode a word
Hello
JBSWY3DP
5 bytes is exactly one Base32 block, so there is no padding.
Encode text and files to Base32 or decode Base32 back, with the RFC 4648, base32hex and Crockford alphabets. Useful for 2FA secrets, DNS records and readable IDs.
= signs, then copy or download the result.Hello
JBSWY3DP
5 bytes is exactly one Base32 block, so there is no padding.
Hi!
JBUSC===
3 bytes fill 5 characters, and three = signs complete the 8-character block.
MZXW6YTBOI======
foobar
This is the official example from RFC 4648, section 10.
jbswy3dp
Hello
Base32 is case-insensitive, so lowercase input decodes to the same bytes.
Base32 encodes binary data using 32 characters: the letters A–Z and the digits 2–7. It reads the input 5 bits at a time and maps each 5-bit value (0 to 31) to one character. Because it uses only one letter case and leaves out the confusing digits 0, 1 and 8, Base32 is easy to read aloud, type by hand and use in case-insensitive systems. It is defined in RFC 4648, section 6.
The trade-off is size: Base32 turns every 5 bytes into 8 characters, so the output is 60% larger than the input. Standard Base64 only adds 33%.
Base32 processes the input in blocks of 5 bytes (40 bits), which split evenly into eight 5-bit groups. Here is Hi! (3 bytes):
| Step | Value | ||
|---|---|---|---|
| Bytes | H = 0x48 | i = 0x69 | ! = 0x21 |
| Bits | 01001000 01101001 00100001 | ||
| 5-bit groups | 01001 00001 10100 10010 0001 + 0 (zero-filled) | ||
| Values | 9, 1, 20, 18, 2 | ||
| Characters | J B U S C + === padding → JBUSC=== | ||
When the input is not a multiple of 5 bytes, the last block is completed with = signs so the output length is always a multiple of 8.
| Bytes in the last block | Characters | Padding |
|---|---|---|
| 1 | 2 | ====== (6) |
| 2 | 4 | ==== (4) |
| 3 | 5 | === (3) |
| 4 | 7 | = (1) |
| 5 | 8 | none |
| Value | Char | Value | Char | Value | Char | Value | Char |
|---|---|---|---|---|---|---|---|
| 0 | A | 8 | I | 16 | Q | 24 | Y |
| 1 | B | 9 | J | 17 | R | 25 | Z |
| 2 | C | 10 | K | 18 | S | 26 | 2 |
| 3 | D | 11 | L | 19 | T | 27 | 3 |
| 4 | E | 12 | M | 20 | U | 28 | 4 |
| 5 | F | 13 | N | 21 | V | 29 | 5 |
| 6 | G | 14 | O | 22 | W | 30 | 6 |
| 7 | H | 15 | P | 23 | X | 31 | 7 |
All three use 5 bits per character. They only differ in the alphabet:
| Variant | Alphabet | foobar encodes to | Used for |
|---|---|---|---|
| RFC 4648 (standard) | A–Z 2–7 | MZXW6YTBOI====== | 2FA/TOTP secrets, most libraries |
| base32hex (RFC 4648 §7) | 0–9 A–V | CPNMUOJ1E8====== | DNSSEC NSEC3 records; keeps sort order |
| Crockford | 0–9 + letters without I, L, O, U | CSQPYRK1E8 | Human-readable IDs, ULIDs |
base32hex keeps the same sort order as the original bytes, which matters when encoded values are compared as strings. Crockford's Base32 removes I, L, O and U to avoid confusion with 1, 0 and accidental words. When decoding, it reads O as 0 and I or L as 1, ignores hyphens, and normally uses no padding. ULIDs are written in Crockford's Base32.
Authenticator apps such as Google Authenticator, Microsoft Authenticator and Authy store TOTP secrets as Base32. The QR code you scan contains a URI like this:
otpauth://totp/dev247:[email protected]?secret=JBSWY3DPEHPK3PXP&issuer=dev247The secret parameter is the shared key in Base32, usually without padding. Base32 was chosen because people sometimes have to type the key by hand, and it avoids lookalike characters and case mistakes. Treat it like a password: anyone who has it can generate your codes.
.onion.import base64 encoded = base64.b32encode(b'Hello').decode() # "JBSWY3DP"decoded = base64.b32decode('jbswy3dp', casefold=True) # b"Hello" # base32hexhexed = base64.b32hexencode(b'foobar').decode() # "CPNMUOJ1E8======"echo -n 'Hello' | base32 # JBSWY3DPecho 'JBSWY3DP' | base32 --decode # Hello # Other alphabets with basencecho -n 'foobar' | basenc --base32hex # CPNMUOJ1E8======Browsers and Node.js have no built-in Base32, but the encoder is short:
const ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'; function base32Encode(bytes, pad = true) { let out = '', buffer = 0, bits = 0; for (const byte of bytes) { buffer = (buffer << 8) | byte; bits += 8; while (bits >= 5) { out += ALPHABET[(buffer >> (bits - 5)) & 31]; bits -= 5; } } if (bits > 0) out += ALPHABET[(buffer << (5 - bits)) & 31]; while (pad && out.length % 8) out += '='; return out;} base32Encode(new TextEncoder().encode('Hello')); // "JBSWY3DP"PHP has no built-in Base32 either. For security-sensitive values such as TOTP secrets, use a constant-time library like paragonie/constant_time_encoding:
use ParagonIE\ConstantTime\Base32; $encoded = Base32::encodeUpper('Hello'); // "JBSWY3DP"$decoded = Base32::decodeUpper($encoded); // "Hello"binascii.Error: Non-base32 digit found (Python)
The input has lowercase letters, spaces or characters outside A–Z 2–7. Pass casefold=True, remove spaces, and check for 0, 1 or 8, which do not exist in the RFC 4648 alphabet (they usually mean the value is Crockford or base32hex).
binascii.Error: Incorrect padding (Python)
The = signs were removed, which is common for 2FA secrets. Add them back until the length is a multiple of 8: s + "=" * (-len(s) % 8).
An authenticator app says the secret key is invalid
The key was copied with spaces, hyphens or lowercase letters, or it was given in a different encoding. Remove spaces and use uppercase. If decoding here fails, the key is probably not Base32.
The same input gives a different result in another tool
The tools use different alphabets. Check whether the value should be RFC 4648, base32hex or Crockford, and whether padding is expected. The Variant option switches between them.
"That length can't come from whole bytes"
A Base32 value can never end with 1, 3 or 6 characters in its last group of 8. A character was lost or added while copying.
No. The standard alphabet is uppercase, but decoders treat lowercase letters the same. This tool accepts both.
The RFC 4648 alphabet uses 2–7 so that 0, 1 and 8 cannot be confused with the letters O, I/L and B. That makes values easier to read aloud and type by hand.
About 60% larger: every 5 bytes become 8 characters. Base64 is more compact (33%), but it is case-sensitive and less readable.
The standard RFC 4648 alphabet (A–Z 2–7), usually without the = padding.
Crockford's Base32 uses 0–9 plus 22 letters, leaving out I, L, O and U. When decoding, it treats O as 0 and I and L as 1, ignores hyphens and usually has no padding. It is designed for IDs that people read and type.
No. Encoding and decoding run entirely in your browser, which matters when you work with real 2FA secrets.
Free, private developer tools that run in your browser. No signup, nothing uploaded, no waiting.
Tip: press Ctrl D to bookmark dev247.