StringMash.com

Base64 encode and decode

Encode text to Base64 or decode it back, with URL-safe and MIME variants.

Conversion
12 characters
Updates as you type
16 characters

Using the Base64 encoder

Type or paste on the left, read the encoded text on the right. Swap the boxes to decode, or go to the decoder if that's the job.

Character set decides how your text becomes bytes before encoding. Leave it on UTF-8 unless you know the text came from an older system. Variant picks the output alphabet: Standard, URL-safe for anything headed into a web address, or MIME, which wraps at 76 characters the way email expects.

How Base64 works

Base64 reads three bytes at a time and writes them as four characters from a 64-character alphabet. Three bytes is 24 bits; four characters carry six bits each. The arithmetic is exact, and the output is a third longer than the input.

When the input doesn't divide by three, the last group is padded and the output ends in one or two = signs. That padding is the easiest way to recognise Base64 on sight, and a length that isn't a multiple of four means something was cut off.

64 CHARACTERS

The Base64 alphabet

CharactersValues
A–Z0–25
a–z26–51
0–952–61
+62
/63
=padding

Why it exists

Email was built for text, and for years it was built for seven-bit text. Push raw bytes through it and gateways would strip the eighth bit, rewrite line endings, or read a stray byte as a control code. Anything that wasn't plain English arrived broken.

Base64 was the workaround, and MIME standardised it for attachments in 1992. Every photo you've ever emailed made the trip this way, a third larger than it sat on disk.

It never left. Data URIs embed images in stylesheets with it, JSON Web Tokens use the URL-safe variant for each of their three parts, and keys and certificates get passed around as Base64 because they paste into a terminal without breaking.

Related conversions

Base64, hexadecimal and binary write the same bytes at different densities: eight digits per byte, two, and about 1.33 characters.

For the number behind each character rather than the bytes behind the text, see character codes and Unicode code points.

Questions

Is Base64 encryption?

No. Anyone can decode it. It changes how data is written, not who can read it.

What is URL-safe Base64?

A variant that swaps + for - and / for _, so the result survives a web address without extra escaping. JSON Web Tokens use it.

Why is my output a third bigger?

Four characters carry three bytes. That overhead buys safe passage through systems that only handle text.

Why does my decoded text look garbled?

The bytes probably weren't text. Base64 often carries images, PDFs or keys, and those read as noise.