Encode plain text to Base64 or decode Base64 back to text. Supports UTF-8 and emoji. Updates live.
What is Base64 encoding?
Base64 is an encoding scheme that converts binary data into a string of 64 printable ASCII characters (A–Z, a–z, 0–9, +, /) plus = for padding. Every 3 bytes of input become 4 Base64 characters, so encoded data is about 33% larger than the original. Common uses include: embedding images directly in HTML or CSS (data:image/png;base64,…), JWT tokens (header and payload are Base64url-encoded), HTTP Basic Authentication (Authorization: Basic dXNlcjpwYXNz), and encoding binary data for safe transport in JSON, XML, or email (MIME). Base64 is not encryption — it is trivially reversible and provides no security.
Base64 in Python
import base64
# Encode
text = "Hello, World! 🌍"
encoded = base64.b64encode(text.encode('utf-8')).decode('ascii')
print(encoded) # SGVsbG8sIFdvcmxkISDwn4yN
# Decode
decoded = base64.b64decode(encoded).decode('utf-8')
print(decoded) # Hello, World! 🌍
# Encode a file (e.g., an image)
with open('image.png', 'rb') as f:
img_b64 = base64.b64encode(f.read()).decode('ascii')
Base64 in JavaScript
// Encode (handles UTF-8)
const encode = (str) => btoa(unescape(encodeURIComponent(str)));
// Decode (handles UTF-8)
const decode = (b64) => decodeURIComponent(escape(atob(b64)));
// Node.js (no browser APIs needed)
const encoded = Buffer.from('Hello, World!').toString('base64');
const decoded = Buffer.from(encoded, 'base64').toString('utf-8');