Skip to content
All tutorials

/tutorials/what-base64-encoding-does

What Base64 Encoding Actually Does

Why Base64 exists, how it turns binary data into plain text, and why it is not, and was never meant to be, a form of encryption.

5 min read

Run Base64 Encoder

The problem Base64 was created to solve

A great deal of internet infrastructure, particularly older email systems, was built to reliably carry plain text but not arbitrary binary data such as images or other files. Base64 exists to bridge that gap: it takes any binary data and re-represents it using only 64 printable characters, letters, digits, plus and slash, so it can pass safely through systems that only expect text, without any bytes being lost or misinterpreted along the way.

How it actually works, briefly

Base64 reads data three bytes, twenty four bits, at a time and re-splits those bits into four six bit groups, each one mapped to one of the sixty four allowed characters. This is why encoded output is consistently about a third larger than the original data, and why its length is always a multiple of four characters, padded with an equals sign at the end when the input does not divide evenly into three byte groups.

Why this is not encryption

Base64 is fully reversible by anyone, instantly, with no key or password required at all, since the mapping between six bit groups and characters is fixed and completely public. Anyone who ever describes hiding a password by Base64 encoding it as security has made a genuine mistake, because decoding it back to the original text takes a single line of code or a free tool like the one on this page, no different from unwrapping a package rather than actually locking it.

Trying it yourself

A short piece of text and its Base64 encoded form

Hello, world!
->
SGVsbG8sIHdvcmxkIQ==

Notice the trailing equals sign, added because the original text's length did not divide evenly into three byte groups. Decoding the encoded string back with the Base64 Encoder returns the original text exactly, with nothing lost or altered.

Using the Base64 Encoder

The Base64 Encoder handles both directions entirely in your browser, so nothing you type is sent anywhere. It is worth remembering that anything you encode here is exactly as readable to anyone else who has the encoded text, since encoding, unlike encryption, was never meant to keep anything secret.