Base64 Explained: What It Is and When to Use It
Developer · Published October 5, 2026 · Updated October 24, 2026 · 3 min read
Written by Akinrinmade Michael
Base64 is a way to write any data, even binary data like an image, using only 64 safe characters: the letters A-Z and a-z, the digits 0-9, and + and /. That makes it safe to put inside text formats that can't carry raw bytes. Its smaller sibling, Base32, does the same job with fewer characters, and this guide covers both.
How Base64 works
Base64 takes the input three bytes (24 bits) at a time and splits them into four groups of six bits. Each group of six bits becomes one character from the 64-character alphabet. If the input doesn't divide evenly by three, the output is padded with = signs.
Text: Hello Base64: SGVsbG8=
Here's the first group worked out by hand. The letters Man are the bytes 77, 97 and 110. In binary that's 01001101 01100001 01101110, which regroups into 010011 010110 000101 101110. Those four numbers are 19, 22, 5 and 46, and in the Base64 alphabet they're the characters T, W, F and u. So Man becomes TWFu.
Because four characters carry three bytes, Base64 is about 33% larger than the original.
Where you'll see it
- Data URIs: small images placed straight into HTML or CSS, like
data:image/png;base64,iVBOR.... - Email: attachments are Base64-encoded so they can travel through text-only systems.
- JSON Web Tokens: the header and payload of a JWT are Base64URL-encoded JSON. The JWT decoder shows them.
- HTTP Basic authentication: the
Authorizationheader carriesusername:passwordin Base64. - APIs and config files: binary values such as keys and certificates.
Base64 isn't encryption
Anyone can decode Base64 in a second, so it protects nothing. Never use it to hide passwords or secrets. It only changes how data is written. If a password appears in a Base64 string in a config file or a header, it's effectively sitting there in plain text.
URL-safe Base64
The characters + and / have special meaning in web addresses. The URL-safe variant, called Base64URL, replaces them with - and _ and usually drops the = padding. JWTs use this form. If a string decodes to garbage in one tool and works in another, check which of the two variants it is.
Text with accents and emoji
Base64 works on bytes, not letters. Text must first be converted to bytes, normally with UTF-8, which is why é becomes two bytes and an emoji becomes four. Tools that skip this step fail on non-English text. The Base64 Encoder handles it for you, and the text to binary converter shows the bytes underneath.
Base32: the same idea with fewer characters
Base32 uses 32 characters: the capital letters A to Z and the numbers 2 to 7. Every 5 bytes become 8 characters, so the text is about 60 percent bigger than the original, compared with 33 percent for Base64. In return it leaves out characters that are easy to mix up, such as 0 and O, or 1 and I, and it has no lower case.
That makes it survive being read aloud, typed by hand or stored in systems that ignore case. It's why the secret keys in authenticator apps are shown in Base32 (see the guide to two-factor codes), and why it turns up in file names and some ID formats. The Base32 Encoder supports the standard alphabet, the extended hex one and the Crockford variant, which is designed to be easy to read.
Base32 or Base64?
| Base32 | Base64 | |
|---|---|---|
| Characters | A to Z and 2 to 7 | A to Z, a to z, 0 to 9, plus and slash |
| Size increase | About 60% | About 33% |
| Case-sensitive | No | Yes |
| Easy to read aloud or type | Yes | No |
| Typical use | Authenticator secrets, human-facing codes | Email, data URIs, tokens, APIs |
- Will a person read, type or say it aloud? Use Base32.
- Does size matter, and is it only for machines? Use Base64.
- Is it going in a web address? Use the URL-safe Base64 form.
- Do you need to keep it secret? Neither one helps. Use real encryption.
When not to use Base64
Embedding a large image as Base64 makes your page bigger and stops the browser from caching the image separately. Use data URIs only for small icons, ideally under about 10 KB. For anything bigger, link to the file. The Image to Base64 tool is useful for small icons, and the image compressor is a better first stop for a large photo.