What Is Base64 Encoding? A Simple Explanation
Base64 is one of those things that shows up everywhere — in data URIs, JSON payloads, JWTs, and email attachments — but rarely gets explained. Here's the short version.
What Base64 actually is
Base64 is an encoding, not encryption. It represents binary data (or text) using only 64 "safe" ASCII characters: A–Z, a–z, 0–9, +, and /, with = used for padding. Because those characters survive systems that only expect plain text, Base64 lets you move arbitrary data through text-only channels.
Why developers use it
- Data URIs — embedding a small image directly in HTML/CSS (
data:image/png;base64,…) instead of a separate request. - JSON and APIs — sending binary blobs inside a text field.
- JWTs — the header and payload of a token are Base64URL-encoded.
- Email (MIME) — attachments are Base64-encoded for transport.
How it works, briefly
Base64 takes 3 bytes (24 bits) at a time and splits them into four 6-bit groups. Each 6-bit group (0–63) maps to one character in the Base64 alphabet. When the input isn't a multiple of 3 bytes, = padding fills the gap. That 3-to-4 ratio is why Base64 output is always about 33% larger than the input.
Text: M a n
ASCII: 77 97 110
Bits: 010011010110000101101110
6-bit: 010011 010110 000101 101110
Base64: T W F u -> "TWFu"
When not to use Base64
Base64 is not security. It's trivially reversible, so never use it to "hide" passwords or secrets — anyone can decode it instantly. It also adds size, so it's the wrong choice for large files where a binary transfer would be cheaper.
Related
Part of the Encoding vs Encryption vs Hashing guide. See also Base64 Is Not Encryption and Character Encoding: ASCII, Unicode & UTF-8.
Try it
Paste any text or image and encode or decode it instantly — everything runs in your browser, nothing is uploaded.