Fundamentals · 6 min read

What is Base64 encoding?

Base64 is everywhere — email attachments, data URIs, JWTs, API tokens, PEM certificates. But what is it actually doing? A complete primer.

The one-sentence answer

Base64 is a way of representing binary data — any sequence of bytes — using only 64 printable ASCII characters, so that the data can pass safely through systems that were designed for text.

Why we need it

Most internet protocols were built when text was the only safe transport. Email headers, JSON payloads, HTTP URLs, HTML attributes, XML documents — all of them assume their contents are readable characters. If you try to stuff a raw JPEG into a JSON string, you'll get bytes that aren't valid UTF-8, control characters that break parsers, and quotes that escape the string boundary.

Base64 solves this by mapping every 3 bytes of input to 4 printable characters drawn from a 64-character alphabet: AZ, az, 09, plus + and /. The encoded form contains no control characters, no quotes, no whitespace, no special meaning anywhere. It's the safest possible text representation of arbitrary bytes.

Key idea

Base64 trades size for safety. The encoded form is roughly 33% larger than the original, but it can travel through any text-only channel without corruption.

The alphabet

RangeCharactersCount
Uppercase lettersAZ26
Lowercase lettersaz26
Digits0910
Symbols+, /2
Padding=(special)

The padding character = is appended when the input length isn't a multiple of 3 bytes. One = means one byte of padding; two == means two. The padding is what gives Base64 its characteristic look. (Full explainer on padding here.)

How encoding works, briefly

Take three bytes — 24 bits total. Split them into four 6-bit groups. Each 6-bit group has a value between 0 and 63. Use that value to look up a character in the Base64 alphabet. The result is four characters that represent the original three bytes.

Example: the ASCII text Cat is three bytes: 0x43 0x61 0x74. In binary that's 01000011 01100001 01110100. Split into 6-bit groups: 010000 110110 000101 110100 = 16 54 5 52. Looked up in the alphabet: Q 2 F 0. So Cat encodes to Q2F0.

Where you'll see Base64 in the wild

What Base64 is not

It's not encryption. There's no key. Anyone with a Base64 string can decode it instantly — that's literally what this site does. If you see Base64 used as a "security measure," it's a security mistake. (Why Base64 isn't encryption — and what to use instead.)

It's also not compression. Base64 makes data bigger, not smaller, by roughly 33%. If you need smaller data, use gzip or another compression algorithm before Base64-encoding.

Try it now

Paste any Base64 string into the decoder and watch it become readable text. Try the example SGVsbG8sIHdvcmxkIQ== — that's "Hello, world!" in Base64.


Published May 2026 · Last reviewed May 2026. Spot an error? Email contactus@base64decode.tools.

Run it yourself

Try the decoder.