Intosoft 工具
🔤↔️01

How Base64 Encoding Works

Base64 converts binary data into a text format using 64 printable ASCII characters. It's essential for transmitting data through text-only channels.

64
Characters Used
+33%
Size Increase
6 bits
Per Character
=
Padding Character

The Base64 Alphabet

A-Z (0-25):
ABCDEFGHIJKLMNOPQRSTUVWXYZ
a-z (26-51):
abcdefghijklmnopqrstuvwxyz
0-9 (52-61):
0123456789
+, / (62-63):
+/

These 64 characters are safe in virtually all text systems. The = sign is used for padding.

Step-by-Step Encoding Process

1
Convert to Binary
Each character becomes its 8-bit ASCII/UTF-8 binary representation
"Hi" → 01001000 01101001
2
Group into 6 bits
Split the binary stream into 6-bit chunks (Base64 uses 64 = 2⁶ values)
010010 000110 1001 → Need padding
3
Pad if Needed
Add zeros to make complete 6-bit groups, add = padding at end
010010 000110 100100 (padded)
4
Map to Characters
Each 6-bit value (0-63) maps to a Base64 character
18, 6, 36 → SGk=

Why Does Base64 Increase Size by 33%?

Original: Each byte = 8 bits of data

Base64: Each character represents only 6 bits

Math: 3 bytes (24 bits) → 4 Base64 characters (24 bits)

Result: 4/3 = 1.33... → 33% increase in size

Plus additional overhead from padding (=) and line breaks in some formats.

Base64 Variants

VariantSpecial CharsCommon Use
Standard Base64A-Z, a-z, 0-9, +, /MIME, PEM, general encoding
Base64URLA-Z, a-z, 0-9, -, _URLs, filenames, JWT
Base64 (no padding)Same as standardSome APIs, compact storage

Where Base64 Is Used

📧
Email Attachments (MIME)

SMTP only supports 7-bit ASCII. Base64 encodes binary files for transmission.

🖼️
Data URLs

Embed images directly in HTML/CSS: data:image/png;base64,iVBORw0K...

📋
JSON/XML Payloads

Safely include binary data in text-based formats without escaping issues.

🔐
Basic Authentication

HTTP Basic Auth encodes username:password as Base64 (not encryption!).

🎫
JWT Tokens

JWT header and payload are Base64URL encoded for URL-safe transmission.

🔑
Cryptographic Keys

PEM files store certificates and keys in Base64 between BEGIN/END markers.

Security Warning

Base64 is NOT encryption! It's trivially reversible. Anyone can decode Base64 data instantly. Never use it to "hide" sensitive information like passwords, API keys, or personal data.

For security, use proper encryption (AES, RSA) or hashing (bcrypt, Argon2).

Try Base64 Encoding Now!

Encode and decode Base64 strings instantly with our free tool.

🔤Open Base64 Encoder/Decoder