What is Base64 image encoding?
Base64 encoding converts binary image data into ASCII text. This allows images to be embedded directly in HTML, CSS, or JavaScript as a Data URI, without needing a separate image file or HTTP request.
When to use Base64 images
Use Base64 when:
- Embedding small icons or logos in CSS (avoids HTTP request)
- Inlining images in HTML email templates (some email clients block external images)
- Embedding images in single-file HTML documents
- Passing images through APIs that accept text/JSON
Avoid Base64 when:
- Large images (Base64 is ~33% larger than the original binary)
- Images used on multiple pages (no caching benefit)
- Images that need to be updated frequently
Data URI format
A Base64 Data URI looks like:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...
It consists of:
data:— URI schemeimage/png— MIME type;base64,— encoding indicatoriVBOR...— the actual Base64 encoded image data
Using in HTML
<img src="data:image/png;base64,iVBORw0KGgo..." alt="logo">
Using in CSS
.logo {
background-image: url('data:image/png;base64,iVBORw0KGgo...');
}
File size impact
Base64 encoding increases the file size by approximately 33% compared to the original binary. A 100 KB PNG becomes roughly 133 KB as a Base64 string. For inline use in HTML or CSS, this is usually acceptable for small images. For large images, always use a standard <img src="..."> tag pointing to the actual file.
Email embedding — why it matters
Many email clients (Outlook, Apple Mail, Gmail on some settings) block externally hosted images by default. Embedding images as Base64 Data URIs bypasses this restriction — the image is part of the email body itself and displays without needing to load an external URL.
Security note
Base64 is encoding, not encryption. Anyone can decode a Base64 string back to the original image in seconds. Do not use Base64 to "hide" sensitive images.
How to convert image to Base64 free
- Go to Image to Base64
- Upload your image
- Select output format (Data URI, HTML
<img>, CSS background, etc.) - Copy the result
- Paste directly into your code