Base64 Encode/Decode — Auto-Detect, Image Preview & Data URI
Encode text or files to Base64, decode Base64 back to text, and preview data:image/...;base64, images inline. Auto mode guesses encode vs decode, and errors say exactly what went wrong.
What is Base64 Encoder / Decoder?
Base64 is a binary-to-text encoding scheme that represents arbitrary data using 64 printable ASCII characters. It's the most widely used encoding format on the web.
Zero-Server Tool Data Guarantee
All encoding, decoding, and image previews happen locally in your browser. Text, files, and images never leave your device — no server upload, no logging, no tracking of your data.
How to Use
Pick a Mode
Auto guesses encode vs decode from your input; Encode converts text or files to Base64; Decode reverses the process.
Paste, Type, or Drop a File
Paste text, a Base64 string, or a data:image/...;base64, URI — or drag a file into the input area.
Toggle URL-Safe
Enable 'URL safe (base64url)' to produce JWT/URL-friendly output with - and _ instead of + and /.
Review the Result
Decoded text appears instantly; Base64 that decodes to an image (PNG/JPEG/GIF/WebP/AVIF) renders an inline preview.
Copy
Use the copy button for text output, or 'Copy data URI' to grab the full data:image/...;base64, string.
Common Use Cases
Embed Images in HTML/CSS
Convert binary image data to Base64 for inline data URIs, eliminating separate HTTP requests.
Email Attachments
SMTP only supports 7-bit ASCII; Base64 encodes binary attachments for transport through email systems.
JSON Data Transport
Embed binary data (files, certificates, keys) directly in JSON strings using Base64 encoding.
API Authentication
HTTP Basic Auth uses Base64 to encode 'username:password' in the Authorization header.
Implementation Examples
// Encodeconst encoded = btoa('hello world');// "aGVsbG8gd29ybGQ="// Decodeconst decoded = atob('aGVsbG8gd29ybGQ=');// "hello world"// URL-safe variantconst urlSafe = btoa('hello?world=').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
Base64 vs Base85 vs Hex
| Encoding | Overhead | Character Set | Use Case |
|---|---|---|---|
| Base64 | 33% | 64 chars (A-Z, a-z, 0-9, +, /) | Web, email, APIs, data URIs |
| Base85 | 25% | 85 chars (printable ASCII) | PostScript, PDF, compact storage |
| Hex (Base16) | 100% | 16 chars (0-9, a-f) | Debugging, crypto hashes |
| Base32 | 60% | 32 chars (A-Z, 2-7) | 2FA secrets, case-insensitive |
Production Best Practices & Security
Frequently Asked Questions
Base64 encodes binary data into a safe ASCII string using 64 characters (A-Z, a-z, 0-9, +, /) with = padding.
You need it whenever binary data must travel through text-only channels: embedding images in HTML/CSS (data: URLs), attaching files to emails (MIME), encoding binary in JSON fields (API responses, JWTs), storing binary in text databases, and transmitting cryptographic keys (PEM format wraps Base64).
Base64 is not encryption — it is encoding. Anyone can decode it instantly without a key.