Base64 Encoder/Decoder
Encode & decode Base64, Base32, Hex, Base58 and more — fast, private, no server upload.
What is Base64 Encoding?
Base64 is a binary-to-text encoding scheme defined in RFC 4648. It represents binary data using 64 ASCII characters (A-Z, a-z, 0-9, +, /), making it safe for transmission through text-based protocols like email (MIME), HTTP headers, and URLs.
The name "Base64" refers to the 64-character alphabet used. Each character represents exactly 6 bits of data, so 3 bytes (24 bits) of input produce 4 Base64 characters. This results in a ~33% size increase, which is the trade-off for text compatibility.
Base Encoding Examples
Try these real-world examples instantly. Click Decode → to load each example into the tool and see the result.
| Format | Description | Sample | Try |
|---|---|---|---|
| Base64URL | JWT authentication token | eyJhbGciOiJIUzI1… | |
| Base64 | Data URI — 1×1 transparent PNG | data:image/png;ba… | |
| Base64 PEM | PEM public key certificate | -----BEGIN PUBLIC… | |
| Base58 | Bitcoin genesis block address | 1A1zP1eP5QGefi2D… | |
| Base32 | TOTP authenticator secret | JBSWY3DPEHPK3PXP | |
| Hex | SHA-256 hash of empty string | e3b0c44298fc1c14… | |
| Base85 | Ascii85-encoded "Man is d…" | 9jqo^BlbD-BleB1D… | |
| Base91 | Base91 round-trip sample | fPNKd | |
| Base62 | Short URL / unique ID | 7N42dgm5tFLK9N8M… | |
| Base64 MIME | Email attachment (76-char wrap) | TWFuIGlzIGRpc3Rp… |
Base Encoding Formats Compared
This tool supports 11 base encoding formats. Each has different trade-offs between efficiency, character set, and use case:
| Format | Alphabet | Overhead | Use Case |
|---|---|---|---|
| Base64 | A-Z, a-z, 0-9, +, / | +33% | General purpose, MIME email |
| Base64URL | A-Z, a-z, 0-9, -, _ | +33% | JWT, OAuth, URLs |
| Base32 | A-Z, 2-7 | +60% | TOTP, DNS, case-insensitive |
| Hex | 0-9, A-F | +100% | Colors, MAC, hashes |
| Base58 | 1-9, A-H, J-N, P-Z, a-k, m-z | +37% | Bitcoin, IPFS |
| Base62 | 0-9, A-Z, a-z | +36% | Short URLs, unique IDs |
| Base85 | ! to u (ASCII 33-117) | +25% | PostScript, PDF, ZeroMQ |
| Base91 | 91 printable ASCII | +14-23% | Maximum efficiency |
Common Use Cases
- JWT Tokens — Header and Payload are Base64URL-encoded. Decode them to inspect claims like expiration and issuer.
- PEM Certificates — TLS/SSL certificates use Base64 with
-----BEGIN CERTIFICATE-----headers. Decode to inspect certificate details. - Data URIs — Embed images in HTML/CSS as
data:image/png;base64,.... Encode files to generate Data URIs. - Email Attachments — MIME uses Base64 with 76-character line wrapping to encode binary attachments in email.
- Bitcoin Addresses — Base58Check encoding removes confusing characters (0, O, I, l) for human-readable addresses.
- TOTP Secrets — Google Authenticator uses Base32-encoded secrets for two-factor authentication setup.
Common Base Encoding Errors and How to Fix Them
Invalid padding
Symptom: Invalid padding: expected 0-2 '=' characters or decoding fails silently.
Cause: Base64 strings must have a length that is a multiple of 4. Missing = padding characters break the decoder.
Fix: Add = characters until the string length is a multiple of 4. This tool does it automatically — look for the "Auto-repaired: added padding" message.
Invalid character in Base64 string
Symptom: Invalid character error when decoding.
Cause: The string contains characters outside the Base64 alphabet. Common culprits: - and _ (Base64URL characters) in a standard Base64 decoder.
Fix: Check if the string is Base64URL-encoded (uses -_ instead of +/). Select the correct format or let auto-detect identify it.
Decoded output is garbled or unreadable
Symptom: The decoded result contains random characters or mojibake.
Cause: The wrong encoding format was selected. For example, a Base32 string decoded as Base64 produces garbage output.
Fix: Use auto-detect to identify the correct format, or manually try different formats until the output makes sense.
Base64URL vs Base64 confusion
Symptom: JWT tokens fail to decode with a standard Base64 decoder.
Cause: JWT uses Base64URL encoding which replaces + with - and / with _, and omits padding.
Fix: Select Base64URL format, or paste the JWT and let auto-detect handle it (strings starting with eyJ are automatically detected as JWT/Base64URL).
Odd-length hex string
Symptom: Odd-length hex string error when decoding hex.
Cause: Hex encoding uses 2 characters per byte, so the total length must be even. An odd-length string is missing a leading zero.
Fix: Prepend a 0 to make the length even. For example, change FFF to 0FFF.
Base Encoding in Your Language
Base64 encoding and decoding are available in all major programming languages through standard libraries:
| Language | Module | Encode | Decode |
|---|---|---|---|
| Node.js | Buffer (built-in) | Buffer.from(str).toString('base64') | Buffer.from(b64, 'base64').toString() |
| Python | base64 (built-in) | base64.b64encode(data) | base64.b64decode(s) |
| Java | java.util.Base64 | Base64.getEncoder().encodeToString(bytes) | Base64.getDecoder().decode(s) |
| Go | encoding/base64 | base64.StdEncoding.EncodeToString(data) | base64.StdEncoding.DecodeString(s) |
| .NET/C# | System.Convert | Convert.ToBase64String(bytes) | Convert.FromBase64String(s) |
| PHP | Core (built-in) | base64_encode($data) | base64_decode($s) |
| Ruby | Base64 (built-in) | Base64.strict_encode64(data) | Base64.strict_decode64(s) |
How to Use This Tool
- Select Encode or Decode mode using the buttons above.
- In Encode mode, type or paste text, choose a format, and see the encoded result instantly.
- In Decode mode, paste an encoded string. The tool auto-detects the format and decodes it.
- If the decoded result is JSON, an image, or a PDF, an appropriate viewer is shown automatically.
- Use Code Snippets to copy ready-to-use code for HTML, CSS, Node.js, Python, and more.
- Check the Efficiency Comparison to see how different formats compare in size.
Base64 vs Base32 vs Base58
| Aspect | Base64 | Base32 | Base58 |
|---|---|---|---|
| Characters | 64 (case-sensitive) | 32 (case-insensitive) | 58 (no confusing chars) |
| Overhead | +33% | +60% | +37% |
| Padding | = (0-2) | = (0-6) | None |
| URL-safe | No (+, /) | Yes | Yes |
| Best for | Email, APIs, Data URIs | TOTP, DNS, filenames | Bitcoin, human-readable IDs |
Technical Reference
Complete specification reference for all 11 supported base encoding formats:
| Format | Standard | Alphabet | Size | In:Out | Padding | Max Line |
|---|---|---|---|---|---|---|
| Base64 | RFC 4648 §4 | A-Z, a-z, 0-9, +, / | 64 | 3:4 | = (0-2) | — |
| Base64URL | RFC 4648 §5 | A-Z, a-z, 0-9, -, _ | 64 | 3:4 | Optional | — |
| Base64 MIME | RFC 2045 | A-Z, a-z, 0-9, +, / | 64 | 3:4 | = (0-2) | 76 (CRLF) |
| Base64 PEM | RFC 7468 | A-Z, a-z, 0-9, +, / | 64 | 3:4 | = (0-2) | 64 (LF) |
| Base32 | RFC 4648 §6 | A-Z, 2-7 | 32 | 5:8 | = (0/1/3/4/6) | — |
| Base32 Hex | RFC 4648 §7 | 0-9, A-V | 32 | 5:8 | = (0/1/3/4/6) | — |
| Hex | RFC 4648 §8 | 0-9, A-F | 16 | 1:2 | None | — |
| Base58 | Bitcoin wiki | 1-9, A-H, J-N, P-Z, a-k, m-z | 58 | ~1:1.37 | None | — |
| Base62 | De facto | 0-9, A-Z, a-z | 62 | ~1:1.34 | None | — |
| Base85 | Ascii85 | ! to u (33-117) | 85 | 4:5 | None | — |
| Base91 | basE91 | 91 printable ASCII | 91 | ~1:1.23 | None | — |
Frequently Asked Questions
Is Base64 encoding the same as encryption?
No. Base64 is encoding, not encryption. Anyone can decode Base64 without a key — it simply converts binary data to a text-safe format. For security, use actual encryption algorithms like AES or RSA. Never store sensitive data in Base64 alone.
Why does Base64 increase file size by 33%?
Base64 maps every 3 bytes of input to 4 ASCII characters using 6-bit groups. Since 4/3 ≈ 1.333, the output is always ~33% larger than the input. This trade-off provides safe text transmission through protocols that only support ASCII characters.
When should I use Base64URL instead of standard Base64?
Use Base64URL when the encoded string will appear in URLs or filenames. Standard Base64 uses + and / which have special meaning in URLs. Base64URL replaces them with - and _ and omits padding. JWT tokens always use Base64URL.
What is the difference between Base32 and Base64?
Base32 uses only uppercase letters (A-Z) and digits 2-7, making it case-insensitive with ~60% size overhead. Base64 uses 64 characters (case-sensitive) with ~33% overhead. Base32 is preferred for TOTP secrets and systems where case sensitivity is problematic.
Can I encode binary files like images with Base64?
Yes. Base64 is commonly used to embed images in HTML/CSS as Data URIs (data:image/png;base64,...), encode email attachments (MIME), and transmit binary data through JSON APIs. This tool supports file drag-and-drop for encoding any file type.
Why does Base58 exclude certain characters?
Base58 removes 0 (zero), O (uppercase o), I (uppercase i), and l (lowercase L) from the alphabet to prevent visual confusion when reading addresses. This makes it ideal for Bitcoin addresses and other human-readable identifiers.
What is the maximum size I can encode with this tool?
This tool supports files up to 10MB. All processing happens client-side in your browser, so performance depends on your device. For text input, there is no strict limit, but very large inputs (over 1MB) may cause slower processing.
Is it safe to paste sensitive data like tokens here?
Yes. All processing happens entirely in your browser using JavaScript. Your data is never sent to any server. You can verify this by checking the Network tab in your browser's developer tools.
Features
Multi-Format Support
Encode and decode 11 formats: Base64, Base64URL, MIME, PEM, Base32, Base32 Hex, Hex, Base58, Base62, Base85, and Base91. All in one tool.
Auto-Detection
Paste any encoded string and the tool automatically detects the format — JWT tokens, PEM certificates, Data URIs, hex strings, and more.
Smart Result Preview
Decoded results are analyzed automatically. JSON gets syntax highlighting, images get inline preview, and binary data shows a hex dump.
Code Snippets
Get ready-to-use code for HTML <img>, CSS background-image, Node.js Buffer, Python base64, JavaScript atob, and PowerShell.
File Support
Drag and drop files to encode them, or decode encoded strings back to downloadable files. Supports any file type up to 10MB.
100% Private
All processing happens in your browser using JavaScript. No data is ever sent to any server. Safe for production tokens and sensitive data.
Privacy & Security
Your data is processed entirely in your browser using JavaScript. Nothing is sent to any server. All encoding, decoding, format detection, and file processing happen locally. You can verify this by opening your browser's developer tools and checking the Network tab. This tool is safe to use with production data, API keys, certificates, and sensitive credentials.