← All commands
THE COMMAND REFERENCE

base32

Encode data as base32 text, or decode it back.

Last updated

GNU

Implementation-level reference; examples are not certified for every installed version.

Overview

base32 encodes data using only capital letters A to Z and the digits 2 to 7, plus = for padding. It is longer than base64 but safe in places that ignore case or cannot use symbols. With -d it decodes. Like base64, it is an encoding, not encryption.

Background

Base32 is the encoding described in RFC 4648. base32 is part of GNU coreutils; macOS does not ship it, and the BusyBox 1.37.0 build used for this page has no such applet, so this page has only a GNU view.

Examples

Encode some text:

printf hello | base32

Decode it back with -d:

printf NBSWY3DP | base32 -d

Print the encoded text on one line with -w 0:

printf '%0100d' 0 | base32 -w 0 | grep -c .

Options

-d
Decode instead of encode.

-w, --wrap
Wrap encoded lines after this many characters; -w 0 never wraps.

Common mistakes

Base32 output is about 60 percent bigger than the input, more than base64. Padding with = is part of the standard, so keep it when you pass the text on. Do not confuse it with other base32 alphabets, such as the Crockford variant, which base32 does not produce.

Portability

This page covers GNU only. base64 is the encoding to use when a tool must work everywhere. The Common examples were executed on GNU coreutils 9.11 (see the development guide for the exact check).

About GNU base32

GNU base32 is part of GNU coreutils, and this page's checks ran coreutils 9.11.

References

Original explanations, with upstream documentation for further reading. FreeBSD references are comparison material, not a claim of Apple version equivalence.