Base64 to Text Decoder
Decode Base64 strings back to readable text with our free online decoder. Convert encoded email attachments, API responses, authentication headers, and embedded data back to their original human-readable form. All processing happens locally in your browser for complete privacy.
Base64 Decoding Examples
| Base64 Encoded | Decoded Text |
|---|---|
| SGVsbG8gV29ybGQ= | Hello World |
| dXNlcm5hbWU6cGFzc3dvcmQ= | username:password |
| eyJhbGciOiJIUzI1NiJ9 | {"alg":"HS256"} |
| VGhpcyBpcyBhIHRlc3Q= | This is a test |
| 8J+YgA== | π (emoji) |
Where You'll Encounter Base64
Base64 encoded data appears throughout modern web development and system administration:
- JWT Tokens: The header and payload sections of JSON Web Tokens are Base64URL encoded
- HTTP Basic Auth: Credentials sent as
Authorization: Basic dXNlcjpwYXNz - Email (MIME): Attachments and non-ASCII content in emails
- Data URIs: Embedded images like
data:image/png;base64,iVBORw0... - API Responses: Binary data returned as Base64 strings in JSON
- Configuration Files: Encoded secrets in Kubernetes secrets, CI/CD configs
- Database Blobs: Binary data stored as Base64 text in some databases
Recognizing Base64 Strings
Base64 strings have distinct characteristics that help you identify them:
- Characters: Only A-Z, a-z, 0-9, +, /, and = (or - and _ for URL-safe)
- Length: Always a multiple of 4 (padded with = if needed)
- Padding: Ends with 0, 1, or 2 equals signs
- No spaces: Unless line-wrapped for display (common in emails)
- Pattern: Random-looking but consistent character set
Standard vs URL-Safe Base64
| Feature | Standard Base64 | URL-Safe Base64 |
|---|---|---|
| Character 62 | + | - |
| Character 63 | / | _ |
| Padding | Required (=) | Often omitted |
| Use case | General purpose | URLs, filenames |
Base64 Decoder Implementation
``javascript
// Browser implementation with Unicode support
function base64ToText(base64String) {
try {
// Remove whitespace and line breaks
const cleaned = base64String.replace(/\s/g, '');
// Handle URL-safe Base64
const standard = cleaned
.replace(/-/g, '+')
.replace(/_/g, '/')
.padEnd(Math.ceil(cleaned.length / 4) * 4, '=');
// Decode Base64 to binary string
const binaryString = atob(standard);
// Convert to Uint8Array for proper UTF-8 handling
const bytes = new Uint8Array(binaryString.length);
for (let i = 0; i < binaryString.length; i++) {
bytes[i] = binaryString.charCodeAt(i);
}
// Decode UTF-8 bytes to text
return new TextDecoder('utf-8').decode(bytes);
} catch (error) {
throw new Error('Invalid Base64: ' + error.message);
}
}
// Node.js version
const decoded = Buffer.from(base64String, 'base64').toString('utf-8');
`
Common Decoding Use Cases
Reading JWT Token Contents
`javascript
// Split JWT and decode the payload (middle section)
const [header, payload, signature] = jwt.split('.');
const decodedPayload = JSON.parse(atob(payload));
console.log(decodedPayload.sub); // User ID
`
Extracting Basic Auth Credentials
`javascript
// From "Basic dXNlcm5hbWU6cGFzc3dvcmQ="
const encoded = authHeader.split(' ')[1];
const [username, password] = atob(encoded).split(':');
``
Troubleshooting Decoding Errors
| Error | Cause | Solution |
|---|---|---|
| Invalid character | Non-Base64 chars present | Remove spaces, newlines, or invalid characters |
| Corrupted string | Truncated or modified data | Check for complete transmission |
| Garbled output | Binary data, not text | Data may be an image/file, not text |
| Unicode issues | Multi-byte chars | Use TextDecoder with UTF-8 |
Security Considerations
Base64 is encoding, not encryption. Anyone can decode Base64 dataβit provides no security. Never rely on Base64 to hide sensitive information. If you find Base64-encoded credentials or secrets, they are effectively plaintext.