Base64 Encoder / Decoder – Instant Conversion
Convert text to Base64 or decode Base64 strings back to plain text. 100% client-side, no data leaves your browser. Free, fast, private.
What is Base64 Encoding?
Base64 is a binary‑to‑text encoding scheme that represents binary data in an ASCII string format using a radix‑64 representation. It is commonly used to embed images directly into HTML/CSS, transmit data in URLs without corruption, and store complex data in JSON or XML. The encoding uses 64 characters: A–Z, a–z, 0–9, +, /, and = for padding. Each Base64 character represents 6 bits of the original data.
Base64 is not encryption – it does not hide information. It transforms data so it can be safely transmitted over media that were designed to handle textual data. For example, email attachments (MIME) use Base64 to send binary files as text. Similarly, when you send JSON containing binary data, you may encode it as Base64 to avoid escaping issues.
How Base64 Encoding Works (Technical Example)
The transformation works on byte triplets: three bytes (24 bits) become four Base64 characters (6 bits each). If the input length is not a multiple of 3, padding (=) is added. For example, the ASCII string "Man" (77 97 110 in decimal) encodes to "TWFu". Unicode characters are first UTF‑8 encoded, then Base64‑encoded. Our tool uses standard JavaScript functions `btoa()` (binary to ASCII) and `atob()` (ASCII to binary), with proper UTF‑8 handling to support all Unicode characters including emojis and non‑Latin scripts.
Common Use Cases for Base64
- Email Attachments (MIME): SMTP was originally designed for 7‑bit ASCII. Base64 allows binary files to be attached to emails without corruption.
- Data URIs in HTML/CSS: Embed images directly into HTML or CSS using `data:image/png;base64,
`. This reduces HTTP requests but increases page size. - JSON APIs: When transmitting binary data (e.g., file contents, cryptographic keys) inside JSON, Base64 ensures safe serialization.
- Basic HTTP Authentication: The username:password string is Base64‑encoded in the `Authorization` header.
- Cryptography: Public keys, certificates (PEM format) are often stored as Base64 strings.
- Database Storage: Binary blobs can be stored as Base64 text in text‑only database columns.
Advantages and Limitations of Base64
Advantages: Safe for text‑based protocols, no special characters to escape, widely supported across all programming languages, deterministic encoding (same input always produces same output).
Limitations: Increases data size by approximately 33% (because 3 bytes become 4 characters). Not suitable for extremely large data (e.g., multi‑megabyte images) – for that, use direct binary transfer or compression. Base64 is not a security measure; it does not encrypt or protect data. Anyone can decode it.
Common Errors and Troubleshooting
When decoding, you may encounter “Invalid Base64 string”. This usually means the input contains characters outside the Base64 alphabet (A‑Z,a‑z,0‑9,+,/,=) or incorrect padding. Our tool automatically cleans whitespace, but if the string was corrupted or truncated, decoding will fail. Always ensure you have the complete Base64 string. For binary data (images, PDFs), the decoded output may appear as gibberish text – this is normal because those bytes are not meant to be read as UTF‑8. To handle binary files, use `FileReader` with base64 output.
Is Base64 Safe for Sensitive Data?
Absolutely not. Base64 is a reversible encoding, not encryption. Anyone who sees a Base64 string can decode it in seconds using any online tool (including this one). Never use Base64 to store passwords, tokens, or any confidential information. For security, use proper encryption like AES or hashing like SHA‑256. Base64 is a format, not a protection.
Why Our Tool is Different: 100% Client‑Side, Private
Many Base64 tools send your data to a server for processing – that means your text, passwords, or API keys may be logged or intercepted. Our encoder/decoder works entirely in your browser using JavaScript. No data is ever transmitted. You can disconnect from the internet and it still works. Your privacy is absolute. This is especially important when decoding sensitive information like JWT payloads or private certificates.