Interactive Base64 explainer

What Is Base64?

Base64 is a binary-to-text encoding. It takes bytes, groups their bits, and rewrites them as safe ASCII characters for email, JSON, HTML, URLs, APIs, certificates, and tokens.

Browser-only demoShows bytes, bits, indexes, and padding

Core rule

3

bytes

24 bits

4

characters

4 x 6 bits

Because 24 bits divide cleanly into four 6-bit numbers, each number can choose one character from a 64-character alphabet.

Live encoding lab

Type text and watch Base64 happen

The demo first converts text to UTF-8 bytes, then encodes those bytes. For long input, the bit walkthrough shows the first 18 bytes so the layout stays readable.

Samples

UTF-8 bytes

5

Output chars

8

Padding

1

Expansion

60%

Base64 output

4 x ceil(5 / 3) = 8 characters

SGVsbG8=

Base64URL version

Base64URL swaps + for -, swaps / for _, and usually removes trailing padding.

SGVsbG8

The mechanics

The 24-bit blocks that produce the string

Each block below takes up to three input bytes. Missing bytes at the end become zero bits for calculation, and the corresponding output slots become padding characters.

Block 1

SGVs

Input bytes

0x48H

01001000

0x65e

01100101

0x6Cl

01101100

6-bit indexes

010010

18S

000110

6G

010101

21V

101100

44s

Block 2

bG8=

Input bytes

0x6Cl

01101100

0x6Fo

01101111

zero bits for padding

6-bit indexes

011011

27b

000110

6G

111100

608

000000

pad=

Alphabet lookup

64 characters, indexed 0 through 63

A 6-bit number can represent values from 0 to 63. Standard Base64 maps those values to uppercase letters, lowercase letters, digits, plus, and slash. Highlighted cells are used by the current input.

A0
B1
C2
D3
E4
F5
G6
H7
I8
J9
K10
L11
M12
N13
O14
P15
Q16
R17
S18
T19
U20
V21
W22
X23
Y24
Z25
a26
b27
c28
d29
e30
f31
g32
h33
i34
j35
k36
l37
m38
n39
o40
p41
q42
r43
s44
t45
u46
v47
w48
x49
y50
z51
052
153
254
355
456
557
658
759
860
961
+62
/63

Decode direction

A decoder reverses the lookup table

first 8 output chars

Each Base64 character maps back to a 6-bit number. A decoder joins those bits, cuts them into 8-bit bytes, then removes bytes implied only by padding.

S18

010010

G6

000110

V21

010101

s44

101100

b27

011011

G6

000110

860

111100

=pad

padding

Binary to text

Base64 does not change the meaning of bytes. It only rewrites those bytes as printable ASCII characters.

3 bytes become 4 characters

The encoder reads 24 bits at a time, splits them into four 6-bit numbers, then looks up each number in a 64-character alphabet.

Not encryption

Anyone can reverse Base64 without a key. Use it for transport and embedding, not for hiding passwords or secrets.

Where it fits

Use Base64 when bytes must pass through text-only systems

Email MIME

Binary attachments can move through mail systems that expect text-safe content.

Data URIs

Small images, SVGs, fonts, or other assets can be embedded in HTML and CSS.

JSON and APIs

Binary fields can travel inside text payloads when an API does not accept raw bytes.

JWT and OAuth

Tokens usually use Base64URL, a URL-safe variant of Base64.

Certificates and keys

PEM files wrap DER bytes in Base64 plus readable header and footer lines.

Debugging payloads

Logs and config files often contain encoded bytes that need validation before decoding.

What breaks decoders

Most Base64 errors come from variant, padding, or byte assumptions

Padding

A trailing = or == only fills the final 4-character block. Missing padding is often repairable unless the length mod 4 is 1.

Base64URL

JWTs replace + with - and / with _, and often remove padding. Convert the alphabet before using a standard decoder.

Unicode

Base64 works on bytes. Text must first become bytes, usually UTF-8, before it can be encoded.

Binary output

Decoded bytes are not always readable text. Images, PDFs, ZIP files, and keys should be handled as bytes.

Ready to decode a real value?

Use the private browser decoder for text, files, data URIs, Base64URL, images, PDFs, and suspicious padding.

Base64 Decode

Paste a Base64 string and decode it to readable text, bytes, images, PDFs, or downloadable files in your browser without uploading data to a server.

Base64 Encode

Convert text or files into Base64 strings in your browser, with URL-safe output support and no server-side upload.

Base64 vs Base64URL

Base64URL is a URL-safe variant of Base64 that replaces plus and slash with dash and underscore, and often omits padding.

Base64 Cheatsheet

A quick reference for Base64 characters, URL-safe variants, language code examples, MIME prefixes, and data URI patterns.

Python Base64 Decode

Use Python base64.b64decode() to convert Base64 strings back to bytes, then decode those bytes as text or write them to a file.

JavaScript Base64 Decode

Use atob() for ASCII Base64 in the browser, then use Uint8Array and TextDecoder when decoded bytes may contain Unicode text.

PHP base64_decode

PHP base64_decode() converts Base64 text back to binary data. Use strict mode when validating untrusted input.

Java Base64 Decode

Java uses java.util.Base64 to decode standard, URL-safe, and MIME Base64 into byte arrays that can be converted to strings or files.

Linux Base64 Decode

Use base64 -d on Linux to decode stdin or files. On macOS, use base64 -D with the BSD command.

Data URI Base64

A Base64 data URI embeds file bytes directly inside a URL string, commonly for small images, fonts, SVGs, and CSS assets.

Base64 Decode Online

Decode Base64 online in a private tool that runs locally in your browser, so pasted values and files stay on your device.