How to Encode and Decode Base64
A practical developer's guide to Base64 — what it is, when to use it, and how to convert it in your browser.
What Is Base64 Encoding?
Base64 is a binary-to-text encoding scheme that converts binary data into a string of 64 ASCII characters (A-Z, a-z, 0-9, +, /). It's used when you need to transmit binary data through channels that only support text.
Example:
Text: Hello World
Base64: SGVsbG8gV29ybGQ=
The "=" at the end is padding — it ensures the output length is a multiple of 4 characters.
Common Use Cases for Base64
- Data URIs: Embedding small images directly in HTML or CSS without a separate file request (
data:image/png;base64,iVBOR...) - API authentication: HTTP Basic Auth encodes credentials as Base64 (
Authorization: Basic dXNlcjpwYXNz) - JWT tokens: JSON Web Tokens use Base64url encoding for the header and payload sections
- Email attachments: MIME encoding uses Base64 to embed file attachments in email messages
- Configuration files: Storing binary data (certificates, keys) in text-based configs like YAML or JSON
- URL-safe transmission: Encoding binary data for inclusion in URLs and query parameters
Step-by-Step: Encode and Decode Base64
To Encode (Text → Base64):
- Open the Base64 Encoder
- Paste your plain text into the "Encode to Base64" section
- Click "Encode"
- Copy the Base64 result
To Decode (Base64 → Text):
- Scroll to the "Decode from Base64" section
- Paste your Base64 string
- Click "Decode"
- The original text appears in the output
Base64 in JavaScript
Browsers provide native Base64 functions:
// Encode
const encoded = btoa('Hello World');
// Result: "SGVsbG8gV29ybGQ="
// Decode
const decoded = atob('SGVsbG8gV29ybGQ=');
// Result: "Hello World"
// For Unicode text, use:
const encoded = btoa(unescape(encodeURIComponent('Hola ñ')));
const decoded = decodeURIComponent(escape(atob(encoded)));
Our Base64 tool uses these exact native functions, ensuring reliable and fast encoding in your browser.
Important: Base64 Is NOT Encryption
A common misconception: Base64 is not a security measure. It's an encoding scheme, not encryption. Anyone can decode a Base64 string — there's no secret key involved.
Never use Base64 to "encrypt" passwords, API keys, or sensitive data. Use proper encryption (AES, RSA) or hashing (SHA-256, bcrypt) for security.
Why Use a Browser-Based Base64 Tool?
Developers routinely paste API tokens, JWT payloads, and configuration data into online decoders. With server-based tools, all that sensitive data is transmitted over the internet.
Our tool runs entirely in your browser — perfect for decoding production tokens or auth headers safely. Learn more about browser-based vs cloud tools.
Encode or Decode Base64 Now
Fast, accurate, and private. Runs entirely in your browser.
🔐 Base64 Tool