BASE64 Decode
Ready to try BASE64 Decode?
Access the free online tool now - no registration required
BASE64 Decode - Complete Guide
Base64 decoding reverses the encoding process, converting Base64 text back to its original binary form. This is essential for processing encoded data received from APIs, extracting embedded images, or reading email attachments. The decoder handles both standard and URL-safe Base64 variants.
How It Works
The decoder maps each Base64 character back to its 6-bit value, combines four characters into three bytes, and outputs the original binary data. Padding characters (=) tell the decoder how many bytes to expect at the end. Invalid characters or incorrect padding will cause decoding errors.
Technical Details
Decoding reverses the 64-character mapping: A-Z map to 0-25, a-z to 26-51, 0-9 to 52-61, and + (or -) and / (or _) to 62-63. The decoder must handle both standard (RFC 4648) and URL-safe variants. Line breaks and whitespace should be stripped before decoding. Invalid input (wrong characters or incorrect length) should raise clear errors.
Common Use Cases
- Processing API Responses: Many APIs return binary data (images, files) as Base64 strings in JSON responses.
- Example:
Decoding a profile picture from {"avatar": "iVBORw0KGgo..."}
- Example:
- Extracting Data URIs: Extract and save images embedded in HTML/CSS as data URIs.
- Example:
Parse data:image/png;base64,... and save as PNG file
- Example:
- Reading JWT Tokens: JSON Web Tokens consist of Base64URL-encoded header, payload, and signature.
- Example:
Decode eyJhbGciOiJIUzI1NiJ9 to see {"alg":"HS256"}
- Example:
- Email Attachment Processing: Extract and save attachments from MIME-encoded emails.
Code Examples
Browser JavaScript
// Decode Base64 to string
const decoded = atob('SGVsbG8gV29ybGQ=');
// Result: "Hello World"
// For UTF-8 content (Unicode)
const utf8Decoded = decodeURIComponent(escape(atob(base64String)));
// Save as file
const binary = atob(base64Data);
const bytes = new Uint8Array(binary.length);
for (let i = 0; i < binary.length; i++) {
bytes[i] = binary.charCodeAt(i);
}
const blob = new Blob([bytes], {type: 'image/png'});
atob() decodes Base64 to a string. For binary files, convert to Uint8Array for proper handling.
Python
import base64
# Decode to string
decoded = base64.b64decode('SGVsbG8gV29ybGQ=').decode('utf-8')
# Result: "Hello World"
# Decode and save as file
with open('output.png', 'wb') as f:
f.write(base64.b64decode(base64_string))
# Handle URL-safe Base64
decoded = base64.urlsafe_b64decode(url_safe_string)
b64decode returns bytes. Call .decode("utf-8") for text, or write directly to file for binary.
Tips & Best Practices
- Strip the data URI prefix (data:type;base64,) before decoding
- Remove all whitespace and line breaks from the input
- If decoding fails, try both standard and URL-safe variants
- For text output, ensure you decode UTF-8 after Base64 decoding
- Validate the decoded output matches expected format (check file signatures for images)
Common Mistakes to Avoid
- Not removing the data URI scheme prefix before decoding
- Forgetting to handle UTF-8 decoding for international text
- Treating binary output as text, causing display issues
- Not handling both padded and unpadded Base64 variants
When to Use This Tool
Use Base64 decode when you receive Base64-encoded data and need the original content - whether it's text, images, or other binary files. Essential for API integrations, email processing, and data URI extraction.
Frequently Asked Questions
Why does my decoded output look like garbage?
The decoded data might be binary (image, compressed file, etc.) displayed as text. Try saving it as a file with the correct extension. If it's supposed to be text, check if it was UTF-8 encoded before Base64 encoding.
What does "invalid Base64" error mean?
Common causes: 1) Invalid characters (Base64 only uses A-Z, a-z, 0-9, +, /, =), 2) Wrong length (must be divisible by 4), 3) Incorrect padding. Try removing whitespace, line breaks, or any prefix like "data:image/png;base64,".
How do I decode Base64URL format?
Base64URL uses - instead of + and _ instead of /. Most decoders handle both automatically. If yours doesn't, replace these characters before decoding: str.replace(/-/g, "+").replace(/_/g, "/").
Can I decode Base64 without padding (=)?
Yes, padding is technically optional for decoding since the missing bytes can be inferred from length. Most modern decoders handle unpadded Base64 correctly. If yours fails, add padding: while (str.length % 4) str += "=".
How do I know if data is Base64 encoded?
Look for: 1) Only contains A-Z, a-z, 0-9, +, /, = characters, 2) Length is divisible by 4 (with padding), 3) Ends with 0-2 = characters. However, some random text can match these criteria, so context matters.
Get Started
Ready to try BASE64 Decode? Use the tool now - it's free, fast, and works right in your browser.
Last updated: June 27, 2026
Start using BASE64 Decode
Free, fast, and privacy-focused - try it now
Share this article
Related Tools
BASE32 Decode
BASE32 Decode tool for developers. Encode and decode data instantly. Ideal for API testing, data transmission, and secure data handling. Free, fast, and browser-based.
BASE32 Encode
BASE32 Encode tool for developers. Encode and decode data instantly. Ideal for API testing, data transmission, and secure data handling. Free, fast, and browser-based.
BASE58 Decode
BASE58 Decode tool for developers. Encode and decode data instantly. Ideal for API testing, data transmission, and secure data handling. Free, fast, and browser-based.
BASE58 Encode
BASE58 Encode tool for developers. Encode and decode data instantly. Ideal for API testing, data transmission, and secure data handling. Free, fast, and browser-based.