Base64 Encode / Decode/ Client-side
Encode and decode Base64 with full Unicode support, URL-safe mode, and zero server uploads.
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
// 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);
}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("=")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!"))# Encode echo -n "Hello, World!" | base64 # Decode echo "SGVsbG8sIFdvcmxkIQ==" | base64 -d # URL-safe encode (GNU coreutils) echo -n "Hello" | base64 | tr '+/' '-_' | tr -d '='