Base64 Encode / Decode/ Client-side

Encode and decode Base64 with full Unicode support, URL-safe mode, and zero server uploads.

Plain Text
Base64 Output
Output will appear here…
Input0 chars
Output0 chars

Did this tool solve your problem?

What is Base64 encoding

Base64 is an encoding scheme that represents binary data using 64 printable ASCII characters. It encodes every 3 bytes (24 bits) into 4 characters, using only A-Z, a-z, 0-9, +, / and the = padding character. Base64 is NOT an encryption algorithm — it's an encoding format that anyone can easily decode, providing no security.

Common Base64 use cases

Email attachments: MIME protocol uses Base64 for binary attachments. Data URLs: embed images, fonts and other resources directly in CSS or HTML to reduce HTTP requests. API transmission: encode binary data (images, PDFs) to JSON as Base64 strings. JWT tokens: the header and payload portions of JWTs are Base64-encoded JSON. Basic authentication: HTTP Basic Auth encodes username:password as Base64.

How much does Base64 increase file size

Base64 encoding increases data size by approximately 33%. Since every 3 original bytes become 4 characters, the encoded size = ceil(original_size / 3) × 4. For large files, transmitting raw binary is more efficient. But when you must use a text-only channel (JSON, XML, URLs) to transmit binary data, Base64 is the standard solution.

Code Examples

JavaScript (Browser)
// Encode (ASCII only)
const encoded = btoa("Hello, World!");
// Decode
const decoded = atob(encoded);

// Encode Unicode (CJK, emoji, etc.)
function b64Encode(str) {
  const bytes = new TextEncoder().encode(str);
  const bin = String.fromCharCode(...bytes);
  return btoa(bin);
}
function b64Decode(b64) {
  const bin = atob(b64);
  const bytes = Uint8Array.from(bin, c => c.charCodeAt(0));
  return new TextDecoder().decode(bytes);
}
Python
import base64

# Encode
text = "Hello, 世界 🌏"
encoded = base64.b64encode(text.encode("utf-8")).decode()
print(encoded)

# Decode
decoded = base64.b64decode(encoded).decode("utf-8")
print(decoded)

# URL-safe variant
url_safe = base64.urlsafe_b64encode(
    text.encode("utf-8")
).decode().rstrip("=")
Go
import "encoding/base64"

// Encode
encoded := base64.StdEncoding.
    EncodeToString([]byte("Hello, World!"))

// Decode
decoded, err := base64.StdEncoding.
    DecodeString(encoded)

// URL-safe
urlSafe := base64.URLEncoding.
    EncodeToString([]byte("Hello, World!"))
Shell (curl / openssl)
# Encode
echo -n "Hello, World!" | base64

# Decode
echo "SGVsbG8sIFdvcmxkIQ==" | base64 -d

# URL-safe encode (GNU coreutils)
echo -n "Hello" | base64 | tr '+/' '-_' | tr -d '='

Frequently Asked Questions

What is Base64?
Base64 is an encoding scheme that converts binary data into ASCII text using 64 printable characters (A–Z, a–z, 0–9, +, /). It's widely used to transmit binary data (images, files) through text-based protocols like HTTP, email, and JSON.
Is Base64 encoding the same as encryption?
No. Base64 is encoding, not encryption. Anyone can decode it instantly — there's no key or secret involved. For data security, use a proper encryption algorithm like AES or RSA.
What's the difference between Base64 and base64url?
Standard Base64 uses + and / which require URL-escaping (%2B and %2F), plus = padding. base64url replaces + with -, / with _, and removes trailing =, making it safe for use in URLs and filenames without escaping. JWT tokens use base64url for the header and payload.
Why does Base64 increase the data size?
Base64 represents every 3 bytes of binary data as 4 ASCII characters, increasing the encoded size to ~133% of the original — roughly a 33% overhead. This is the cost of representing binary data as plain text.
How do I use Base64 in JavaScript?
Browsers provide btoa() (encode) and atob() (decode). However, they don't natively handle Unicode; for strings containing non-Latin characters, you first encode to UTF-8 bytes via TextEncoder, then encode the binary string. This tool handles Unicode correctly.
Is my data safe?
Yes. This tool runs entirely in your browser with no network requests — your data never leaves your device. Feel free to paste sensitive text for testing.