If you've worked with APIs, email attachments, or web development, you've likely encountered Base64 — strings of letters, numbers, and symbols that look like scrambled text. Here's what it is, how it works, and when to use it.
The Problem Base64 Solves
Computers store everything as binary data — sequences of 0s and 1s. But many communication protocols were designed to handle only printable text characters. Sending binary data (images, files, certificates) through these text-only systems can corrupt the data.
Base64 solves this by encoding any binary data into a safe set of 64 printable ASCII characters: A–Z, a–z, 0–9, +, and /, with = used for padding.
How Base64 Encoding Works
The process converts groups of 3 bytes (24 bits) into 4 Base64 characters (6 bits each):
- Take 3 bytes of input data
- Split them into four 6-bit groups
- Map each 6-bit group to a character in the Base64 alphabet
Example: The text Man becomes TWFu in Base64.
If the input isn't a multiple of 3 bytes, = padding characters are added to complete the final group.
Where You'll Encounter Base64
Email Attachments
The MIME standard uses Base64 to encode file attachments in emails. Your email client encodes files before sending and decodes them on receipt — automatically, behind the scenes.
Data URLs
Images and fonts can be embedded directly into HTML or CSS as Base64 data URLs:
<img src="data:image/png;base64,iVBORw0KGgo...">
This avoids a separate HTTP request but increases file size by ~33%.
JSON Web Tokens (JWT)
JWTs use Base64url encoding (a URL-safe variant) for their header and payload sections. You can decode any JWT's header and payload without a key — the signature is what provides security, not the encoding.
HTTP Basic Authentication
The HTTP Basic Auth header sends credentials as username:password encoded in Base64. This is why HTTPS is essential when using Basic Auth — Base64 is trivially reversible.
SSL/TLS Certificates
PEM format certificates (the ones in .pem or .crt files) are Base64-encoded DER certificates wrapped in -----BEGIN CERTIFICATE----- headers.
Base64 Is Not Encryption
This is the most important thing to understand: Base64 encoding is completely reversible without any key. Anyone who sees Base64 data can decode it instantly. It provides zero security — only format compatibility.
Never use Base64 to "hide" sensitive information. Use actual encryption for that.
Try It Yourself
You can encode and decode Base64 instantly in your browser with our Base64 encoder/decoder tool — no data is sent to any server, everything runs locally.
Conclusion
Base64 is a practical encoding format for transmitting binary data through text-only systems. You'll encounter it constantly in web development, APIs, and security contexts. Just remember: it's encoding, not encryption. Use our Base64 tool whenever you need to encode or decode data quickly.