What is Base64?
Base64 is a binary-to-text encoding scheme that converts binary data into a set of 64 printable ASCII characters (A-Z, a-z, 0-9, +, /). Its purpose is simple: represent any data in a format that can safely travel through text-based systems like email, JSON, HTML, and URLs.
Think of Base64 as a universal translator — it takes something a computer can read but a text system can’t (raw bytes) and turns it into something every text system can handle.
How Base64 Works
Base64 takes every 3 bytes (24 bits) of input and splits them into 4 groups of 6 bits. Each 6-bit group maps to one of the 64 characters in the Base64 alphabet. If the input isn’t a multiple of 3 bytes, padding characters (=) are added at the end.
This means Base64 output is always about 33% larger than the original input — a 3MB file becomes roughly a 4MB Base64 string.
Common Use Cases
Data URLs in HTML/CSS
Embed small images directly in your HTML or CSS without separate file requests:
<img src="data:image/png;base64,iVBORw0KGgo..." alt="Icon" />
This eliminates HTTP requests for small assets like icons and logos.
HTTP Basic Authentication
The Authorization header uses Base64 to encode username and password:
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
Note: This is encoding, not encryption. Anyone can decode it — always use HTTPS.
API Data Transfer
When you need to send binary data (like file contents) through a JSON API, Base64 encoding is the standard approach.
Email Attachments (MIME)
Email protocols were originally designed for text. MIME uses Base64 to encode file attachments so they can travel through email servers without corruption.
Base64 is NOT Encryption
This is the most common misconception. Base64 is encoding, not encryption. It provides zero security — anyone can decode a Base64 string back to its original form. If you need security, use encryption algorithms like AES, not Base64.
Try It Yourself
Use the free Base64 Encoder on 4uses to encode and decode text instantly. All processing happens in your browser — your data never leaves your device.
Need to encode URLs instead? Try our URL Encoder for percent-encoding special characters in web addresses.
Common Pitfalls
- Padding errors: Missing
=padding characters can cause decode failures - Character set issues: Some Base64 variants use different characters (URL-safe Base64 replaces
+and/with-and_) - Size bloat: Remember that Base64 increases data size by ~33% — don’t use it for large files unnecessarily
Bookmark the Base64 Encoder for your next encoding task.