How to use the Base64 Encoder & Decoder
- Toggle the Encode or Decode tab depending on your objective.
- Paste your plain text or Base64 string into the Input box.
- Enable URL-Safe Base64 if embedding the string in a URL query parameter or JWT token (replaces `+` and `/` with `-` and `_`).
- Or select a local image/document using Encode Local File to generate a Base64 data URI.
- Click Copy result or Download file to use the output in your code.
The Fundamentals of Base64 Binary-to-Text Encoding (RFC 4648)
Base64 is a binary-to-text encoding scheme designed to transport arbitrary binary data across legacy network protocols and text-only transport layers (such as MIME email bodies, HTTP headers, XML documents, and JSON payloads). In ancient computing standards like ASCII and SMTP, transmitting raw 8-bit bytes frequently caused byte-mangling or command injection because certain control characters (such as null bytes, carriage returns, or escape characters) were reserved by intermediary gateways.
Base64 solves this by mapping every 3 binary bytes (24 bits) into 4 printable ASCII characters (6 bits each) chosen from an alphabet of 64 standard characters:
Size Overhead: Output Length = 4 × ⌈Input Bytes ÷ 3⌉ (approx. +33% byte expansion)
Standard Base64 vs. URL-Safe Base64
| Feature | Standard Base64 (RFC 4648 §4) | URL-Safe Base64 (RFC 4648 §5) |
|---|---|---|
| Character 62 | + (plus sign) | - (hyphen / minus) |
| Character 63 | / (slash) | _ (underscore) |
| Padding Character | = (equals sign) | Omitted or optional |
| Primary Use Cases | MIME email, Data URIs, Basic Auth headers, PEM certificates | JSON Web Tokens (JWT), URL query parameters, REST API IDs |
Why Legacy JavaScript window.btoa Breaks on Unicode
Many basic web tools use JavaScript's built-in window.btoa() and window.atob() functions directly. However, the original browser specification for btoa only accepts Latin1 (ISO-8859-1) characters (byte values 0 to 255). As soon as user text contains an emoji (e.g. 🚀), Cyrillic, Chinese, or Arabic characters, btoa throws an Uncaught DOMException: The string to be encoded contains characters outside of the Latin1 range.
This tool utilizes modern standards-compliant TextEncoder and TextDecoder APIs, ensuring full multi-byte UTF-8 Unicode support without character corruption.
Real-World Engineering Applications of Base64
- Inline Data URIs: Web developers embed small icons directly inside CSS or HTML (e.g.
<img src="data:image/png;base64,iVBOR...">) to eliminate additional HTTP round-trips. - HTTP Basic Authentication: Web servers authorize API requests by decoding credentials from the
Authorization: Basic <base64(user:password)>header. - Cryptographic Keys & Certificates: OpenSSL, SSH public keys, and TLS certificates (PEM files) wrap raw binary ASN.1 structures inside Base64 blocks bounded by
-----BEGIN CERTIFICATE-----.
Frequently asked questions
Is Base64 a form of encryption?
Why does Base64 increase file size by 33%?
What do the equal signs (=) at the end of a Base64 string mean?
What is URL-Safe Base64?
Are my files or passwords uploaded to a server?
How large of a file can I encode?
Last reviewed November 2026. Results are estimates for information only — see our disclaimer.