Developer

What Is Base64 Encoding? A Plain-English Explanation

Base64 turns binary data into text so it can travel safely through text-only systems. Here is what it actually does, why it exists, and when you should use it.

ยท7 min readยทTOOLBeans Team
๐Ÿ”„

Free Tool

Base64 Encoder / Decoder

No account ยท No install ยท Runs in browser

Open Tool โ†’

The Problem Base64 Solves

Computers store everything as binary โ€” ones and zeros. Text is also binary under the hood, but text systems have agreed-upon rules for which binary patterns mean which characters. The problem is that some binary data โ€” images, audio files, encrypted content โ€” contains byte patterns that collide with special control characters in text systems.

Send an image file through an old email server that treats certain byte sequences as "end of message" and your file arrives corrupted. Or try to embed binary data in a JSON field and the quote characters inside the data break the JSON structure.

Base64 was created to solve this. It converts any binary data into a string that uses only 64 safe characters: the 26 uppercase letters, 26 lowercase letters, digits 0โ€“9, and two symbols (+ and /). No matter what the original data contains, the output is always plain, printable text that can safely pass through any text-only system.

How the Encoding Actually Works

Base64 takes your input data three bytes at a time. Three bytes is 24 bits. It splits those 24 bits into four groups of 6 bits each. Each 6-bit group becomes an index into the Base64 alphabet, which maps to one of the 64 safe characters.

The result: every 3 bytes of input becomes 4 characters of output. That is why Base64 increases file size by about 33%. You get text-safety in exchange for about a third more data.

If your input is not a multiple of three bytes, padding characters (=) are added at the end to keep the structure consistent.

Where You See Base64 in the Real World

Email attachments โ€” The MIME standard uses Base64 to encode attachments so they survive email systems that only handle plain text. Every PDF you send via email is Base64-encoded in transit.

Data URLs โ€” When you see <img src="data:image/png;base64,iVBORw..."> in HTML, that is an entire image encoded as Base64 and embedded directly in the HTML file. No separate image request needed.

Basic authentication โ€” HTTP Basic Auth encodes the username and password as Base64 before sending them in the Authorization header. Note: this is encoding, not encryption. Base64 is trivially reversible.

JWT tokens โ€” JSON Web Tokens use Base64 URL encoding (a slight variant) for their header and payload sections.

Storing binary data in JSON โ€” When an API needs to return an image, certificate, or other binary blob inside a JSON response, Base64 is the standard way to do it.

Base64 Is Not Encryption

This is the most common misconception. Base64 is encoding โ€” it is a completely reversible transformation with no secret key involved. Anyone can decode it immediately. It is not meant to protect data, just to make it text-safe.

If you need to protect data, use encryption. If you just need to transmit binary data through a text channel, Base64 is the right tool.

How to Encode and Decode

You can use our free Base64 Encoder/Decoder tool โ€” paste any text or upload a file and get the Base64 output instantly. Paste Base64 back in to decode it. No installation, no account, nothing stored on our end.

In code: JavaScript has btoa() to encode and atob() to decode. In Python, it is base64.b64encode() and base64.b64decode(). In terminal on Mac or Linux, base64 and base64 -d handle it.

Related Topics

base64 encodingbase64 encoder decoderwhat is base64base64 explainedencode decode base64
๐Ÿ”„

Try it yourself

Base64 Encoder / Decoder

Everything in this article is available in the free tool. No account, no subscription, no install.

Open Base64 Encoder / Decoder โ†’