Base64 vs Hex vs Base32: Which Encoding Should You Use?

Base64, hexadecimal and Base32 all solve the same problem — turning binary data into printable text — but they trade off compactness, readability and alphabet size differently. Here is how they compare, and how to pick the right one.

The core tradeoff: alphabet size vs. output size

Every binary-to-text scheme packs a fixed number of input bits into each output character. Hex uses a 16-character alphabet and packs 4 bits per character, so every byte (8 bits) becomes exactly 2 hex characters — a 100% size increase. Base32 uses 32 characters and packs 5 bits per character, for roughly a 60% increase. Base64 uses 64 characters and packs 6 bits per character, for about a 33% increase — the smallest of the three. See the exact math in why Base64 makes files ~33% larger.

Readability and human-friendliness

Hex is the easiest to read at a glance — each byte maps to exactly two characters (0-9, a-f), which is why it is the default for hashes (MD5, SHA), colors, and memory addresses. Base32 avoids visually ambiguous characters like 0/O and 1/I/l, and is case-insensitive, which makes it a good fit for codes a person might type by hand — TOTP two-factor secrets and some license keys use Base32 for this reason. Base64 is the least human-friendly of the three (mixed case, plus + and / symbols) but wins on compactness, which is why it dominates machine-to-machine formats like data URIs, JWTs and API payloads.

Quick comparison

The text Hi (bytes 0x48 0x69) encodes as: hex 4869 (4 characters), Base32 JBQW4=== (8 characters with padding), Base64 SGk= (4 characters). At this tiny size the difference is marginal, but it scales linearly with input — for a 1 MB file, Base64 output is roughly 250 KB smaller than the equivalent Base32 output.

When to use which

Use hex for hashes, checksums, colors, and anywhere you or a teammate will read the value directly. Use Base32 for short human-entered secrets where case-sensitivity and character ambiguity would cause errors. Use Base64 (or its URL-safe variant) for everything else — API payloads, data URIs, tokens, and any binary data that needs to move through a text-only channel as compactly as possible. Try it with the Base64 converter or the hex to Base64 tool.

Base64 vs Hex vs Base32 — FAQ

Which is more compact: Base64, Base32 or hex?+

Base64 is the most compact of the three: it adds about 33% overhead, versus 60% for Base32 and 100% (double size) for hex.

Why would I ever use hex instead of Base64?+

Hex is easier to read and debug byte-by-byte (each pair of characters is exactly one byte), and its 16-character alphabet avoids case-sensitivity issues entirely — useful for hashes, colors and memory addresses.

Why would I use Base32 instead of Base64?+

Base32 is case-insensitive and excludes visually ambiguous characters (0/O, 1/I/l), making it a better fit for values a human might need to type by hand, like TOTP secret keys or short-lived codes.

Is Base32 the same alphabet in every implementation?+

No. RFC 4648 defines a standard Base32 alphabet, but variants exist (e.g. Crockford's Base32) with different character sets and padding rules — always check which variant a library uses.