Base64 Encoding Explained
What Base64 is, why it exists, how it differs from encryption, and common uses like data URIs and email attachments โ with practical examples.
Base64 is a way to represent binary data using only 64 printable ASCII characters (AโZ, aโz, 0โ9, +, /). It lets you safely move binary content through systems that expect text.
Why it exists
Many protocols โ email, URLs, JSON, HTTP headers โ were designed for text. Raw bytes can break them. Base64 converts bytes into text so they survive the trip, at the cost of about 33% larger size.
Base64 is not encryption
This is the most common misconception. Base64 is encoding, not encryption โ it provides no security. Anyone can decode it instantly. Use it for transport formatting, never to hide secrets.
Common uses
- Embedding images directly in HTML/CSS as data URIs.
- Encoding email attachments (MIME).
- The header and payload of a JWT (Base64URL variant).