Skip to content

↑↓ navigate ↵ open Esc close Search runs locally

Base32 Encode & Decode Online

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.

  • Runs in your browser
  • Nothing is uploaded
  • Free, no sign-up
0 BUTF-8
Base32
Runs in your browser. Nothing is uploaded. Tip: drop a file onto the left box

How to use the Base32 tool#

  1. Choose Encode to turn text or a file into Base32, or Decode to turn Base32 back into its original bytes.
  2. Pick the Variant: RFC 4648 for 2FA secrets and most tools, base32hex for DNSSEC, or Crockford for human-friendly IDs.
  3. Type or paste into the left box. Decoding ignores spaces and letter case, and Crockford mode also ignores hyphens.
  4. Turn Add = padding off if the target system expects Base32 without = signs, then copy or download the result.

Examples#

Encode a word

Input
Hello
Output
JBSWY3DP

5 bytes is exactly one Base32 block, so there is no padding.

Encode with padding

Input
Hi!
Output
JBUSC===

3 bytes fill 5 characters, and three = signs complete the 8-character block.

Decode an RFC 4648 test vector

Input
MZXW6YTBOI======
Output
foobar

This is the official example from RFC 4648, section 10.

Decode a lowercase value

Input
jbswy3dp
Output
Hello

Base32 is case-insensitive, so lowercase input decodes to the same bytes.

What is Base32?#

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%.

How Base32 works#

Base32 processes the input in blocks of 5 bytes (40 bits), which split evenly into eight 5-bit groups. Here is Hi! (3 bytes):

StepValue
BytesH = 0x48i = 0x69! = 0x21
Bits01001000 01101001 00100001
5-bit groups01001 00001 10100 10010 0001 + 0 (zero-filled)
Values9, 1, 20, 18, 2
CharactersJ 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 blockCharactersPadding
12====== (6)
24==== (4)
35=== (3)
47= (1)
58none

The Base32 alphabet (RFC 4648)#

ValueCharValueCharValueCharValueChar
0A8I16Q24Y
1B9J17R25Z
2C10K18S262
3D11L19T273
4E12M20U284
5F13N21V295
6G14O22W306
7H15P23X317

Base32 variants: RFC 4648, base32hex and Crockford#

All three use 5 bits per character. They only differ in the alphabet:

VariantAlphabetfoobar encodes toUsed for
RFC 4648 (standard)A–Z 2–7MZXW6YTBOI======2FA/TOTP secrets, most libraries
base32hex (RFC 4648 §7)0–9 A–VCPNMUOJ1E8======DNSSEC NSEC3 records; keeps sort order
Crockford0–9 + letters without I, L, O, UCSQPYRK1E8Human-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.

Base32 in two-factor authentication#

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:

plaintext
otpauth://totp/dev247:[email protected]?secret=JBSWY3DPEHPK3PXP&issuer=dev247

The 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.

Where Base32 is used#

  • TOTP and HOTP secrets for two-factor authentication (RFC 6238).
  • DNSSEC NSEC3 hashed owner names, which use base32hex.
  • ULIDs and other sortable IDs, in Crockford's Base32.
  • Tor v3 onion addresses, which are 56 Base32 characters followed by .onion.
  • File names and case-insensitive systems where Base64's mixed case would collide.

Base32 in code#

Python#

python
import base64 encoded = base64.b32encode(b'Hello').decode()      # "JBSWY3DP"decoded = base64.b32decode('jbswy3dp', casefold=True)  # b"Hello" # base32hexhexed = base64.b32hexencode(b'foobar').decode()    # "CPNMUOJ1E8======"

Command line (GNU coreutils)#

bash
echo -n 'Hello' | base32            # JBSWY3DPecho 'JBSWY3DP' | base32 --decode   # Hello # Other alphabets with basencecho -n 'foobar' | basenc --base32hex   # CPNMUOJ1E8======

JavaScript#

Browsers and Node.js have no built-in Base32, but the encoder is short:

javascript
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#

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:

php
use ParagonIE\ConstantTime\Base32; $encoded = Base32::encodeUpper('Hello');   // "JBSWY3DP"$decoded = Base32::decodeUpper($encoded);  // "Hello"

Common errors and fixes#

  • 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.

Frequently asked questions#

Is Base32 case-sensitive?

No. The standard alphabet is uppercase, but decoders treat lowercase letters the same. This tool accepts both.

Why does Base32 skip the digits 0, 1 and 8?

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.

How much larger is Base32 than the original data?

About 60% larger: every 5 bytes become 8 characters. Base64 is more compact (33%), but it is case-sensitive and less readable.

Which Base32 variant do authenticator apps use?

The standard RFC 4648 alphabet (A–Z 2–7), usually without the = padding.

What is the difference between Base32 and Crockford Base32?

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.

Is my data uploaded?

No. Encoding and decoding run entirely in your browser, which matters when you work with real 2FA secrets.

Your next tool is one search away.

Free, private developer tools that run in your browser. No signup, nothing uploaded, no waiting.

Browse all tools

Tip: press Ctrl D to bookmark dev247.