Base64 Encode & Decode
Convert strings or raw files to Base64 format and vice versa instantly.
Input String / File
Loading editor...
Base64 Render Output
Loading editor...
Need to encode an API key for HTTP Basic Auth, decode a Base64 data URI, or convert binary data for JSON transport? This tool converts between plain text and Base64 in real time as you type.
Last Updated: May 5, 2025Privacy: 100% Local Browser Processing
What is the Base64?
A Base64 Encoder/Decoder converts text strings to and from Base64 encoding — a binary-to-text scheme that represents any data as printable ASCII characters using a 64-character alphabet (A-Z, a-z, 0-9, +, /). Base64 is used extensively in web development for embedding images in HTML/CSS (data URIs), encoding HTTP Basic Authentication credentials, transmitting binary data in JSON payloads, and handling email attachments.
Pro Tips & Best Practices
- Base64 is encoding, NOT encryption. Never use it to 'secure' sensitive data — anyone can decode it instantly. Use proper encryption (AES, RSA) for security.
- If your Base64 decoding produces garbage characters, the original data might be binary (an image, PDF, or compressed file) rather than text. Try decoding to a file instead.
- Base64URL (used in JWTs and URLs) replaces + with - and / with _ to avoid URL-encoding issues. This tool handles standard Base64; use our JWT Decoder for Base64URL.
- When embedding images as Base64 data URIs, remember that the resulting CSS/HTML file will be ~33% larger than the original image. For images over 10KB, a regular file is usually more efficient.
Technical Deep Dive
Base64 encoding works by taking every 3 bytes (24 bits) of input and splitting them into 4 groups of 6 bits each. Each 6-bit group is then mapped to one of 64 printable ASCII characters. If the input length is not a multiple of 3, the output is padded with '=' characters. This process increases data size by approximately 33% (4/3 ratio), which is the inherent overhead of encoding binary data as text. This tool uses JavaScript's built-in btoa() and atob() functions for ASCII text, and a TextEncoder/TextDecoder pipeline for full UTF-8 support. The UTF-8 handling is critical because btoa() only works with Latin-1 characters — attempting to encode emoji, Chinese characters, or any non-Latin text with btoa() directly throws an error. The tool works around this by first encoding the string to UTF-8 bytes using TextEncoder, then encoding each byte as a Latin-1 character, and finally applying btoa(). The reverse process (decoding) reverses these steps. This ensures that any Unicode text — including emoji — can be safely Base64 encoded and decoded.
How to Use
- 1Type or paste your plain text to encode it to Base64.
- 2Or paste a Base64 string to decode it back to plain text.
- 3The conversion happens in real time as you type.
- 4Click Copy to copy the encoded/decoded result.
- 5Supports full UTF-8 character encoding including emoji.
Real-World Use Cases
- HTTP Basic Authentication — encode 'username:password' pairs for the Authorization header (Authorization: Basic dXNlcjpwYXNz).
- Data URIs — decode Base64-encoded images embedded in CSS or HTML (data:image/png;base64,...) to inspect or modify them.
- API payloads — encode binary data (images, files) for transport in JSON API requests that do not support binary content.
- Email debugging — decode MIME-encoded email attachments and body content during email delivery troubleshooting.