RelicRELIC
Developer copy and paste

What is Base64 encoding?

Base64 turns binary data into plain text so it can travel safely through systems that only understand text. It looks cryptic, but it is one of the simplest ideas in computing, and it is not encryption. This explainer covers what it does, why it exists, and where you keep bumping into it.

Jordan Gibbs June 29, 2026 6 min readUpdated July 1, 2026

You have seen it even if you did not know its name. A long, dense run of letters, digits, plus signs and slashes, often ending in one or two equals signs, sitting inside an email header, a config file, or the middle of a web page’s source. That is Base64. It is a way of rewriting any data, including raw binary, as a string of plain text characters that almost any system will accept without choking.

The reason it exists is older than it looks. Plenty of the channels we move data through were built to carry text and only text. Email is the classic example. Send a raw image or a zip file straight down a protocol designed for ASCII and some byte will eventually be misread, mangled, or stripped out. Base64 sidesteps that by restricting itself to a small, safe set of characters that survive the trip intact.

What Base64 actually does

Computers store everything as bytes, and a byte can hold any of 256 values. The problem is that a lot of those values are not printable characters. Some are control codes, some get interpreted as line breaks or end-of-data markers, and some get quietly altered by the systems they pass through. Base64 solves this by mapping arbitrary bytes onto a fixed alphabet of 64 characters that are known to be safe: the 26 uppercase letters, the 26 lowercase letters, the 10 digits, and two extras, usually + and /.

The mechanism is tidy. Base64 reads your data in groups of 3 bytes. Three bytes is 24 bits, and 24 divides neatly into four 6-bit chunks. Each 6-bit chunk can represent a number from 0 to 63, which is exactly one character from the 64-character alphabet. So every 3 bytes of input become 4 characters of output. That four-for-three ratio is why a Base64 string is always about a third larger than the data it represents.

The padding, explained

Your data is rarely a perfect multiple of 3 bytes. When the final group comes up short, Base64 still emits a full block of 4 characters and signals the shortfall with the = sign. One equals means the last group had two bytes, two equals means it had one. The padding is just bookkeeping so a decoder knows exactly how many real bytes to reconstruct. It is structure, not content, which is why those trailing equals signs are such a giveaway that you are looking at Base64.

A quick way to see all of this for yourself: paste any text or upload a small file into our Base64 encoder and decoder and watch the output change character by character. Encoding and decoding both run entirely in your browser, so nothing you paste ever leaves your device.

The most important thing to understand: it is not encryption

This is the single biggest misconception, and it matters. Base64 looks scrambled, so people assume it hides something. It does not. There is no key, no password, and no secret involved. The transformation is completely reversible by anyone, and decoding takes no special permission. If you Base64-encode a password and paste it into a file, you have not protected it at all. You have just made it slightly less obvious to a human skimming the file, while leaving it trivially readable to any machine, and most people.

Encoding and encryption answer different questions. Encoding asks “how do I represent this data in a form this system accepts?” Encryption asks “how do I make this data unreadable to everyone except the holder of the key?” Base64 is firmly in the first camp. It is closer in spirit to a hash function only in that both transform data, but even that comparison breaks down fast: a hash is one-way and Base64 is two-way by design. If the difference between scrambling for transport and scrambling for secrecy is fuzzy, our piece on hashing versus encryption draws the lines clearly.

Where you will run into it

Once you know the shape of a Base64 string, you start seeing it everywhere. A few of the common places:

  • Email attachments. Every image, PDF and document you attach to an email is Base64-encoded behind the scenes so it can ride through a text-based mail protocol. This is the original use case, and it is still the biggest one by volume.
  • Data URLs. A small image embedded directly in HTML or CSS with data:image/png;base64,followed by a wall of characters is a Base64-encoded file, inlined so the browser does not need a separate request.
  • JWTs. The header and payload of a JSON Web Token are Base64-encoded JSON. That is why you can decode a JWT and read its contents without any key, and why you should never put secrets in one.
  • Basic Authentication. HTTP Basic Auth sends your username and password joined by a colon and Base64-encoded in a header. Encoded, not encrypted, which is exactly why Basic Auth must only ever run over HTTPS.
  • Keys and certificates. The PEM format you see in .pem and .crtfiles, with its BEGIN and END markers, wraps Base64-encoded binary key material so it can sit safely in a text file.

URL-safe Base64 and other variants

The two extra characters in the standard alphabet, + and /, cause trouble in some places. A forward slash means something specific in a URL, and a plus sign can be read as an encoded space. So there is a URL-safe variant that swaps those two for - and _, and often drops the padding entirely. JWTs use this URL-safe form. It is the same idea with two characters changed, so a slightly different-looking string should not throw you.

You will also see Base64 strings broken into fixed-width lines, particularly in email and PEM files. That line wrapping is cosmetic, a holdover from old format limits, and a decoder ignores it.

When to reach for it, and when not to

Use Base64 when you genuinely need to carry binary data through a text-only channel: embedding a tiny image in a stylesheet, stuffing a small blob into a JSON field, or moving a key around as text. It is the right tool for those jobs and it is everywhere for good reason.

Avoid it for two things. First, never treat it as security. If the data needs to stay private, encrypt it. Second, be wary of Base64-ing large files when you have an alternative, because that 33 percent size penalty adds up and there is usually a more efficient path. Beyond that, it is a quiet, reliable workhorse. If you spend time in a terminal, it sits right alongside the other formats worth understanding, like the UUID, and it is one more thing that makes copying and pasting in the terminal feel less like guesswork.

Frequently asked questions

Is Base64 encryption?

No. Base64 is encoding, not encryption. It scrambles nothing and hides nothing. Anyone can decode a Base64 string back to the original in a fraction of a second with a built-in tool, no password or key required. If you need to keep data secret, you need real encryption like AES, not Base64.

Why does Base64 make data bigger?

Base64 represents every 3 bytes of input with 4 characters of output, so the result is about 33 percent larger than the original. That is the trade for making binary data safe to move through text-only systems. For small payloads it rarely matters, but it is one reason you avoid Base64 for large files when you have a better option.

What does the equals sign at the end of a Base64 string mean?

The trailing = or == is padding. Base64 works in blocks of 4 characters, and the padding fills out the final block when the input length is not an exact multiple of 3 bytes. One = means the last block held two bytes, two = signs mean it held one. It is structural, not part of the data.

Written by
Jordan GibbsFounder, Relic

Jordan Gibbs is the founder of Relic, an end-to-end encrypted, permanent, searchable memory for everything you copy. He writes widely about AI, agents, and practical tooling on Medium, where he is read by tens of thousands, and builds privacy-first software. Here he covers how everyday tools like the clipboard actually work, and how to use them without handing your data to someone else.

MediumGitHubLinkedIn
Part of
Developer copy and paste
Keep reading
Pillar·8 min

How to copy and paste in the terminal

Ctrl C cancels a command in the terminal, so copy and paste works differently there. Getting it right in Windows Terminal, macOS, Linux, tmux, Vim and over SSH.

Read
7 min

How to copy in cmd, accurately

Copying in the Windows command line is not like copying anywhere else, because Ctrl+C already cancels commands there. The classic cmd window, Windows Terminal, and the clip piping tricks.

Read
7 min

What is a UUID?

A UUID is a 128-bit value designed to be unique without any central authority handing it out. What they are, how the versions differ, and when to reach for one.

Read
developerencryption