What is Base64?

Base64 is a binary-to-text encoding scheme that converts binary data into a string made up of 64 printable ASCII characters. The "64" in the name refers to the size of this character set — 64 symbols that can be safely transmitted through systems that only handle plain text.

It was designed to solve a fundamental compatibility problem: many protocols and systems (email, JSON, XML, HTTP headers) are built for text. But images, audio files, certificates, and executable binaries are binary data — they contain bytes that have no printable representation. Base64 bridges that gap by representing any binary data using only printable characters.

💡 One-line definition

Base64 takes any binary data and turns it into a string of safe, printable text — so it can travel through text-only systems without getting corrupted.

Encode any text to Base64 or decode any Base64 string — free, browser-only, instant results.

Open Base64 Tool →

The Base64 Character Set

Base64 uses exactly 64 characters — 26 uppercase letters, 26 lowercase letters, 10 digits, and 2 symbols (+ and /). A 65th character — the equals sign (=) — is used as padding and is not part of the encoding alphabet itself.

ABCDEFGHIJKLM NOPQRSTUVWXYZ abcdefghijklm nopqrstuvwxyz 0123456789 +/ =
A–Z (26 chars, values 0–25)
a–z (26 chars, values 26–51)
0–9 (10 chars, values 52–61)
+ / (2 chars, values 62–63)
= (padding only)

How Base64 Encoding Works

Base64 encodes data in groups of 3 bytes (24 bits) at a time, converting each group into 4 Base64 characters (6 bits each). Here's how "Man" is encoded step by step:

1
Input text
M   a   n
↓ Convert each character to ASCII byte value
2
ASCII bytes (decimal)
77   97   110
↓ Convert to binary (8 bits each)
3
Binary (24 bits total)
01001101   01100001   01101110
↓ Split into 4 groups of 6 bits
4
6-bit groups (decimal values)
010011 (19)   010110 (22)   000101 (5)   101110 (46)
↓ Map each value to Base64 alphabet
5
Base64 output
T W F u

So "Man" (3 bytes) encodes to "TWFu" (4 characters). Every 3 bytes of input produces exactly 4 characters of Base64 output — a 4:3 ratio, which is why Base64 data is always about 33% larger than the original.

The = padding explained

If the input length is not a multiple of 3, padding characters (=) are added. 1 remaining byte → 2 Base64 chars + == padding. 2 remaining bytes → 3 Base64 chars + = padding.

Live Encode / Decode Tool

Type or paste text below to encode or decode Base64 instantly:

Base64 Encoder / Decoder
Plain Text
Base64 Output
⚠️ Invalid Base64 — check your input for invalid characters.

Real-World Use Cases

Base64 appears in more places than most developers realise:

📧

Email Attachments

MIME encoding uses Base64 to embed binary attachments (PDFs, images) in plain-text email messages.

🖼️

Inline Images (Data URIs)

Embed images directly in HTML or CSS without extra HTTP requests using data:image/png;base64,...

🔐

HTTP Basic Auth

The Authorization header encodes credentials as Base64: Authorization: Basic dXNlcjpwYXNz

🪙

JWT Tokens

JSON Web Tokens use Base64URL (a URL-safe variant) to encode the header and payload sections.

🔑

API Keys & Secrets

Many API platforms encode keys and secrets as Base64 strings for transmission through HTTP headers.

📜

SSL Certificates

PEM-format certificates (.pem, .crt) are Base64-encoded DER files wrapped in -----BEGIN CERTIFICATE----- headers.

Size Overhead

Base64 encoding always increases data size by approximately 33%. This is an inherent cost of representing 3 bytes as 4 characters.

Original dataOriginal sizeBase64 sizeIncrease
Small API token30 bytes~40 chars+33%
Thumbnail image10 KB~13.3 KB+33%
Profile photo100 KB~133 KB+33%
PDF document1 MB~1.33 MB+33%
⚠️ Performance note

Inlining large images as Base64 data URIs increases HTML/CSS file size significantly and can slow page load. Only use Base64 for small icons and images — serve large images as separate files.

Base64 vs Encryption — A Critical Difference

This is one of the most important things to understand about Base64: Base64 is not encryption. It provides zero security.

🚨 Security warning

Storing passwords, API secrets, or personal data as Base64 in source code or databases provides no security whatsoever. Use proper encryption (AES, RSA) or hashing (bcrypt, Argon2) for sensitive data.

Base64 in Code

Every major language has built-in Base64 support. Here are the most common patterns:

JavaScript (Browser)

// Encode const encoded = btoa("Hello, World!"); // → "SGVsbG8sIFdvcmxkIQ==" // Decode const decoded = atob("SGVsbG8sIFdvcmxkIQ=="); // → "Hello, World!" // Unicode-safe encode (handles non-ASCII) const encoded = btoa(unescape(encodeURIComponent("Hello 🌍")));

Python

import base64 # Encode encoded = base64.b64encode(b"Hello, World!").decode("utf-8") # → 'SGVsbG8sIFdvcmxkIQ==' # Decode decoded = base64.b64decode("SGVsbG8sIFdvcmxkIQ==").decode("utf-8") # → 'Hello, World!'

Node.js

// Encode const encoded = Buffer.from("Hello, World!").toString("base64"); // Decode const decoded = Buffer.from("SGVsbG8sIFdvcmxkIQ==", "base64").toString("utf-8");

PHP

// Encode $encoded = base64_encode("Hello, World!"); // Decode $decoded = base64_decode("SGVsbG8sIFdvcmxkIQ==");

Encode or decode Base64 instantly — no code needed. Free, browser-only, nothing transmitted.

Open Base64 Tool →

Frequently Asked Questions

Base64 is a binary-to-text encoding scheme that converts binary data into a string of 64 printable ASCII characters. It is used to safely transmit binary data — images, files, certificates — through systems that only support plain text, such as email and JSON APIs.
No. Base64 is encoding, not encryption. It provides zero security — anyone can decode a Base64 string instantly without a key or password. Never use Base64 to protect sensitive data. Use proper encryption (AES, RSA) or hashing (bcrypt) instead.
Base64 encodes in groups of 3 bytes. If the input is not a multiple of 3 bytes, padding characters (=) are added to complete the last group. One = means one padding byte; == means two padding bytes. If the input length is a multiple of 3, no padding is needed.
Base64 increases data size by approximately 33%. Every 3 bytes of input become 4 characters of output — a 4:3 ratio. A 100KB image becomes approximately 133KB when encoded as Base64.
Base64URL is a URL-safe variant of Base64 that replaces + with - and / with _ to avoid conflicts with URL special characters. It also typically omits the = padding. Base64URL is used in JWT tokens and other web contexts where standard Base64 characters would need URL encoding.

Conclusion

Base64 is one of those foundational encoding schemes that powers a surprising amount of everyday web infrastructure — email attachments, JWT authentication, inline images, SSL certificates, and HTTP auth headers all rely on it. Understanding how it works makes debugging API responses, reading log files, and working with binary data significantly easier.

The most important thing to remember: Base64 is encoding, not encryption. It changes how data is represented, not how secure it is.

Encode text to Base64 or decode any Base64 string instantly — browser-only, free, nothing transmitted.

Open Base64 Tool →

Related Tools