Base64 Encode Online

Free online Base64 encoder & decoder. Instantly convert text to/from Base64. No signup.

Paste any text in the input box and click Base64 Encode to convert it instantly. Paste a Base64 string and click Base64 Decode to reverse the conversion. All processing runs locally in your browser — no data is sent to any server.

What is Base64?

Base64 is a binary-to-text encoding scheme defined in RFC 4648. It represents binary data using a set of 64 printable ASCII characters: A–Z, a–z, 0–9, +, and /. Every 3 bytes of input are mapped to 4 Base64 characters, making the output approximately 33% larger than the original.

Base64 is not encryption — it is trivially reversible without any key. Its purpose is to represent binary data as text so it can pass safely through text-only protocols (email, JSON, HTTP headers).

When is Base64 used?

Email attachments (MIME)
SMTP allows only 7-bit ASCII. MIME encodes attachments (images, PDFs) as Base64 so they survive transit through email servers.
Data URLs in HTML/CSS
Inline images and fonts can be embedded directly as data:image/png;base64,... URIs, eliminating extra HTTP requests for small assets.
JWT tokens
JSON Web Token header and payload segments are Base64url-encoded (a URL-safe variant replacing + with - and / with _).
HTTP Basic Auth
The Authorization: Basic ... header contains credentials as username:password Base64-encoded.

Code examples

JavaScript (browser / Node.js)
// Encode
const encoded = btoa('Hello, World!');  // "SGVsbG8sIFdvcmxkIQ=="

// Decode
const decoded = atob('SGVsbG8sIFdvcmxkIQ==');  // "Hello, World!"

// Unicode-safe encode (handles non-ASCII)
const bytes = new TextEncoder().encode(str);
const bin   = Array.from(bytes, b => String.fromCharCode(b)).join('');
const b64   = btoa(bin);

// Base64url (for JWTs)
const b64url = btoa(str).replace(/\+/g,'-').replace(/\//g,'_').replace(/=+$/,'');
Python
import base64

# Encode
encoded = base64.b64encode(b'Hello, World!').decode()  # "SGVsbG8sIFdvcmxkIQ=="

# Decode
decoded = base64.b64decode('SGVsbG8sIFdvcmxkIQ==').decode('utf-8')

# URL-safe Base64 (no + or /)
safe = base64.urlsafe_b64encode(b'Hello').decode()
curl
# HTTP Basic Auth uses Base64
curl -H "Authorization: Basic $(echo -n 'user:pass' | base64)" \
     https://api.example.com/

Frequently asked questions

What is the = padding at the end of Base64 strings?
Base64 encodes 3 bytes as 4 characters. When the input length is not a multiple of 3, one or two = characters are appended to make the output length a multiple of 4.
What is Base64url?
Base64url (RFC 4648 §5) replaces + with - and / with _, and typically omits = padding. JWT tokens use Base64url for their header and payload segments.
How do I encode an image to Base64?
In Python: base64.b64encode(open('img.png','rb').read()).decode(). In JavaScript (browser): use a FileReader with readAsDataURL() which returns a complete data URI including the Base64 payload.
Why does btoa() fail with non-ASCII characters?
JavaScript's btoa() expects a binary string (characters 0–255). For Unicode text, encode it with TextEncoder to get bytes first, then convert to a binary string before calling btoa(). This tool handles that automatically.

Related tools