Skip to content

Base32 encoding explained, and why two-factor codes use it

Blog / Published 

Base32 turns binary data into text using 32 characters. Each character carries 5 bits, so eight characters represent five bytes. It is less compact than Base64, which uses 64 characters, but it has a useful property: the alphabet is uppercase letters and the digits 2 to 7. There are no look-alike pairs such as 0 and O or 1 and l, so a secret that someone reads aloud or types from a screen is harder to mistype.

The alphabet and the padding

The alphabet is defined in RFC 4648: A to Z followed by 2 to 7. The output length is padded with = characters to a multiple of eight, so a short input ends with one or more equals signs. Many decoders accept input without the padding, but strict ones do not, so check what your tool expects.

Where Base32 shows up

The most common place is two-factor authentication. A TOTP secret is usually shown as a Base32 string, and the authenticator app turns it into a six-digit code every thirty seconds. If you see a secret written in groups of four characters, it is still Base32, just spaced out for reading. Removing the spaces before you use it is the usual fix.

Base32 is also used in some file names and identifiers where case must be ignored, because the alphabet is one case only.

Base32 versus Base64

Use the Base32 tool to encode or decode a value in your browser. For the denser format, the Base64 tool does the same job.

Do not treat it as protection

Base32 is an encoding, not encryption. Anyone who sees a Base32 secret can decode it immediately. Treat a TOTP secret like a password: do not paste it into a public chat or commit it to a repository.

Written by Ján Turský

Creator of TextArray — building free, privacy-first tools that run entirely in your browser.