Developer

Base64 Encoder / Decoder

Encode text to Base64 or decode Base64 back to text instantly.

About the Tool

How Base64 actually works

Base64 solves a very specific problem: how do you move raw binary data through a channel that was only ever designed to carry text? It works by taking three bytes of input (24 bits) and splitting them into four groups of six bits. Each six-bit group is a number from 0 to 63, and that number is looked up in a fixed 64-character alphabet. Three bytes in, four printable characters out - which is why a Base64 string is always roughly one third larger than the data it represents.

The alphabet and the padding character

The standard alphabet runs A–Z, then a–z, then 0–9, and finally the two symbols plus and slash. When the input length is not divisible by three, the encoder pads the final block with one or two equals signs so the output still lines up to a multiple of four characters. That trailing equals sign is padding, not data - it is often the giveaway that you are looking at Base64 rather than, say, a hexadecimal string.

Doing it in code

Most languages ship Base64 in their standard library, so you rarely implement it by hand:

// JavaScript (browser)
const encoded = btoa("Sawubona");   // "U2F3dWJvbmE="
const decoded = atob(encoded);       // "Sawubona"

# Python
import base64
base64.b64encode(b"Sawubona")        # b'U2F3dWJvbmE='
base64.b64decode("U2F3dWJvbmE=")     # b'Sawubona'

URL-safe Base64

Plus and slash both have special meaning inside URLs, so a variant called URL-safe Base64 swaps them for minus and underscore and usually drops the padding. You will see this everywhere in JSON Web Tokens (JWTs), API keys and query-string parameters - anywhere a value needs to survive being pasted into a link without being mangled.

A warning worth repeating

Base64 is encoding, not encryption. Anyone can decode it in seconds, so it offers zero confidentiality - never use it to hide passwords or tokens. The other classic trap is Unicode: the browser btoa function only handles Latin-1, so encoding text with accented characters or emoji throws an error unless you first convert it to bytes with TextEncoder. This tool handles full UTF-8 for you automatically.

More Developer Tools