Base64 Encoder/Decoder
Encode text to Base64 or decode Base64 strings back to readable text. Full UTF-8 support for international characters.
How to Use the Base64 Encoder/Decoder
- To Encode: Select the Encode tab, type or paste your text, and click "Encode to Base64". The Base64-encoded result appears in the output area.
- To Decode: Select the Decode tab, paste your Base64 string, and click "Decode from Base64". The original text appears in the output area.
- Click Copy to copy the result to your clipboard.
- This tool handles UTF-8 characters including emojis, accented letters, and non-Latin scripts.
About Base64 Encoding
Base64 is a group of binary-to-text encoding schemes that represent binary data in an ASCII string format. It uses a set of 64 characters (A-Z, a-z, 0-9, +, /) to represent binary data, with = used as padding. Base64 encoding is widely used in web development, email systems (MIME), and data storage where binary data needs to be stored or transferred as text.
Common use cases include embedding images in CSS or HTML using data URIs, encoding file attachments in emails, storing binary data in JSON or XML, and transmitting data through URLs. While Base64 increases the data size by approximately 33%, it guarantees safe transport through systems that only handle text. Note that Base64 is an encoding scheme, not encryption, and should never be used for security purposes.
Common Base64 Use Cases
Base64 encoding appears throughout web development and software engineering. Here are the most frequent scenarios where you will encounter or need Base64.
Data URIs for Inline Images
Embed small images directly in HTML or CSS to avoid extra HTTP requests:
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAB CAYAAAAC1HAwCAAAAC0lEQVQI12NgAAIABQABNjN9GQAAAAlwSFlzAAAWJQ AAFiUBSVIk8AAAABl0RVh0..." alt="pixel">
Basic Authentication Header
HTTP Basic Auth encodes credentials as Base64:
username:password => dXNlcm5hbWU6cGFzc3dvcmQ= Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
JSON Web Tokens (JWT)
JWTs use Base64URL encoding for the header and payload sections:
Header: {"alg":"HS256","typ":"JWT"}
Base64: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
Payload: {"sub":"1234567890","name":"John"}
Base64: eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4ifQ
Email Attachments (MIME)
Content-Type: application/pdf; name="report.pdf" Content-Transfer-Encoding: base64 JVBERi0xLjQKMSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZwov...
Storing Binary Data in JSON
{
"filename": "photo.jpg",
"content_type": "image/jpeg",
"data": "iVBORw0KGgoAAAANSUhEUgAA..."
}
Base64 Quick Reference
The Base64 alphabet consists of 64 characters plus a padding character. Understanding the encoding table helps when debugging or manually inspecting encoded data.
| Index Range | Characters | Count |
|---|---|---|
| 0 - 25 | A B C D ... Z | 26 |
| 26 - 51 | a b c d ... z | 26 |
| 52 - 61 | 0 1 2 3 ... 9 | 10 |
| 62 | + (or - in Base64URL) | 1 |
| 63 | / (or _ in Base64URL) | 1 |
| Padding | = | 1 |
Size Overhead Comparison
| Original Size | Base64 Size | Overhead |
|---|---|---|
| 1 KB | 1.37 KB | +37% |
| 10 KB | 13.7 KB | +37% |
| 100 KB | 137 KB | +37% |
| 1 MB | 1.37 MB | +37% |
Technical Background: How Base64 Works
Base64 encoding works by taking groups of three bytes (24 bits) from the input and splitting them into four groups of 6 bits each. Each 6-bit group maps to one of 64 characters in the Base64 alphabet (A-Z, a-z, 0-9, +, /). Because 6 bits can represent values 0-63, this creates a one-to-one mapping from bit patterns to printable ASCII characters. When the input length is not a multiple of three bytes, padding with one or two = characters is added to make the output a multiple of four characters.
This encoding scheme was designed to solve a fundamental problem in computing: many data transport systems were built to handle text, not binary data. Email protocols, JSON, XML, HTML, and many database systems can corrupt binary data by interpreting control characters, stripping high bits, or performing character set conversions. By converting binary data to a limited set of universally safe ASCII characters, Base64 guarantees that the data survives transport intact.
The trade-off is a 33% increase in size, since every 3 bytes become 4 characters. For small payloads like authentication tokens, cryptographic keys, or small icons, this overhead is negligible. For large files, the overhead can be significant, which is why file uploads typically use multipart form encoding rather than Base64. The Base64URL variant (replacing + with - and / with _) was created because standard Base64 characters have special meaning in URLs and file systems.
Frequently Asked Questions
Base64 is a binary-to-text encoding scheme that represents binary data using 64 ASCII characters (A-Z, a-z, 0-9, +, /). It is commonly used to embed binary data in text-based formats like JSON, XML, HTML, and email.
Yes. This tool handles UTF-8 encoding properly. It first converts the text to UTF-8 bytes before Base64 encoding, ensuring all Unicode characters including emojis and non-Latin scripts are encoded correctly.
No. Base64 is an encoding scheme, not encryption. It does not provide any security or privacy. Anyone can decode Base64 data back to its original form. It is used for data transport, not data protection.
Base64 encoding increases data size by approximately 33% because it represents every 3 bytes of binary data as 4 ASCII characters. This overhead is the trade-off for being able to safely embed binary data in text-based formats.
The = character is padding used to ensure the Base64 output length is a multiple of 4. If the input byte count is not divisible by 3, one or two = signs are appended. One = means 2 bytes were in the last group; two == means 1 byte was in the last group.
Base64URL is a URL-safe variant that replaces + with - and / with _. It also typically omits the = padding. This variant is used in JSON Web Tokens (JWT), URL parameters, and file names where standard Base64 characters would cause issues.
Yes. Images and other binary files can be Base64 encoded and embedded directly in HTML or CSS using data URIs. This eliminates an extra HTTP request but increases the document size by about 37%. It is best suited for small images like icons and logos under 10 KB.
Email protocols (SMTP/MIME) were designed for 7-bit ASCII text. Binary attachments like images, PDFs, and documents are Base64 encoded so they can be transmitted safely through email systems without data corruption. The email client decodes them automatically on receipt.