Base64 Cheat Sheet

How Base64 works, why it ends in =, the full alphabet, the URL-safe variant, how to recognise what's inside, and how to encode and decode in your language.

Cheat sheetPrintableFree, no login

Updated 28 October 2026

Encode text or files, or decode Base64 back to text or a downloadable file.

Open the Base64 tool

How Base64 works

Base64 turns any bytes into 64 safe text characters. It takes 3 bytes (24 bits) at a time and writes them as 4 characters of 6 bits each, so the output is about 33% larger than the input. Base64 is an encoding, not encryption: anyone can decode it.

InputBytesBase64Why
M1TQ==1 byte β†’ 2 characters + 2 paddingTry β†—
Ma2TWE=2 bytes β†’ 3 characters + 1 paddingTry β†—
Man3TWFu3 bytes β†’ 4 characters, no paddingTry β†—
Hello5SGVsbG8=Try β†—
Hello, World!13SGVsbG8sIFdvcmxkIQ==Try β†—

Output length = 4 Γ— ⌈bytes Γ· 3βŒ‰. For example 100 bytes become 136 characters, and 1,000 bytes become 1,336.

The Base64 alphabet

ValueCharValueCharValueCharValueChar
0A16Q32g48w
1B17R33h49x
2C18S34i50y
3D19T35j51z
4E20U36k520
5F21V37l531
6G22W38m542
7H23X39n553
8I24Y40o564
9J25Z41p575
10K26a42q586
11L27b43r597
12M28c44s608
13N29d45t619
14O30e46u62+
15P31f47v63/

Padding is =. Each Base64 character carries 6 bits, so the value column is the character's 6-bit number.

Standard, URL-safe and MIME Base64

VariantCharacters 62 and 63PaddingUsed in
Standard (RFC 4648)+ /= requiredEmail attachments, data: URLs, most APIs
URL-safe (base64url)- _Usually left outJWTs, URLs, file names
MIME+ /=Email β€” adds a line break every 76 characters
Data URL+ /=data:image/png;base64,iVBORw0KGgo…

The Base64 tool detects URL-safe input and missing padding automatically when decoding.

What's inside? Common Base64 starts

Base64 starts withIt's probably
eyJJSON β€” e.g. a JWT header ({")
iVBORw0KGgoPNG image
/9j/JPEG image
R0lGODGIF image
UklGRWebP image (RIFF container)
JVBERi0PDF document
UEsDBZIP file (also .docx, .xlsx, .jar)
H4sIGzip-compressed data
PD94bWwgXML (<?xml )
PHN2ZySVG image (<svg)

Base64 in code

LanguageEncodeDecode
JavaScript (text)btoa(String.fromCharCode(...new TextEncoder().encode(s)))new TextDecoder().decode(Uint8Array.from(atob(b), c => c.charCodeAt(0)))
Node.jsBuffer.from(s).toString('base64')Buffer.from(b, 'base64').toString()
Pythonbase64.b64encode(data)base64.b64decode(b); URL-safe: urlsafe_b64encode
JavaBase64.getEncoder().encodeToString(bytes)Base64.getDecoder().decode(b)
C# (.NET)Convert.ToBase64String(bytes)Convert.FromBase64String(b)
Gobase64.StdEncoding.EncodeToString(data)base64.StdEncoding.DecodeString(b)
PHPbase64_encode($s)base64_decode($b)
Command linebase64 file.bin or echo -n 'text' | base64base64 -d file.txt (macOS: base64 -D)

JavaScript's btoa() only accepts Latin-1 text, so encode UTF-8 to bytes first, as shown β€” btoa('Γ©πŸ˜€') throws an error.

Gotchas

Frequently asked questions

Why does Base64 end with = or ==?
= is padding. Base64 works on 3-byte groups; if the last group has only 1 or 2 bytes, it's padded so the output length is a multiple of 4.
How much bigger is Base64 than the original?
About 33%: every 3 bytes become 4 characters. 100 bytes become 136 characters, plus line breaks if MIME wrapping is used.
Is Base64 encryption?
No. Base64 is a reversible encoding with no key. Anyone can decode it in a second.
What is the difference between Base64 and Base64URL?
Base64URL swaps + and / for - and _ and usually drops the = padding, so the result is safe in URLs and file names. JWTs use it.
How do I convert an image to Base64?
Use the image to Base64 tool, which gives you a data URL plus ready-made HTML, CSS and Markdown snippets.
βœ“ Copied!