Base64 Images in Email

Last updated: February 2026

How to embed images in HTML emails using Base64 encoding

What Are the Methods for Embedding Images in Email?

Three methods exist for including images in HTML emails: linked images (external URLs), CID attachments (Content-ID references), and inline Base64 (data URIs). Each method carries different tradeoffs in email client compatibility, message size, offline rendering, and deliverability. The table below compares all three approaches across the factors that determine which method to use.

MethodSize ImpactOffline DisplayClient SupportDelivery
Linked (URL)NoneNoUniversalMay be blocked
CID AttachmentFile attachedYesHighLarger email
Inline Base64In HTML bodyYesLimitedLargest email

Linked images reference files hosted on a web server. The email client downloads them when the recipient opens the email, which means the images may be blocked by default in many clients. CID attachments bundle the image file inside the email as a MIME part and reference it using a Content-ID header. Inline Base64 embeds the entire image as a data URI string directly in the HTML source of the email body.

How Do You Embed Base64 Images in HTML Emails?

Use an <img> tag with a data URI in the src attribute. The data URI contains the MIME type and the Base64-encoded image data. The entire image is embedded in the HTML source, requiring no external requests. This approach works in email clients that support data URIs, including Apple Mail and Thunderbird.

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==" alt="Status icon" width="16" height="16" style="display:block;">

The style="display:block;" attribute prevents unwanted spacing around the image in email clients. Always include width, height, and alt attributes for consistent rendering. To generate the Base64 string from an image file, use the Base64 Image Encoder. For ready-to-paste HTML embed code with the data URI already formatted, use the Base64 Embed Code Generator.

Which Email Clients Support Base64 Images?

Email client support for Base64 data URIs is limited compared to linked images and CID attachments. Most webmail clients (Gmail, Outlook.com, Yahoo Mail) strip data URIs during HTML sanitization. Desktop and native mobile clients have broader support. The table below documents current Base64 data URI support by client.

Email ClientBase64 SupportNotes
Apple MailYesFull support on macOS
ThunderbirdYesFull support on all platforms
Gmail (web)NoStrips data URIs from img src
Outlook 365 (web)NoStrips data URIs from img src
Outlook DesktopPartialSome versions support; behavior varies
Yahoo MailNoStrips data URIs from img src
iOS MailYesFull support on iPhone and iPad
Android GmailNoStrips data URIs from img src

Because most webmail clients remove Base64 data URIs, this embedding method is best suited for environments where you control the email client. Internal corporate reports rendered in Apple Mail or Thunderbird are a strong use case. For emails sent to unknown recipients, CID attachments or linked images provide broader compatibility.

What Are the Size Limits for Base64 Email Images?

Base64 encoding adds 33% overhead to image file size. A 30 KB PNG becomes approximately 40 KB of Base64 text. Most email providers enforce total message size limits: Gmail allows 25 MB, Outlook allows 20 MB, and Yahoo Mail allows 25 MB. These limits apply to the entire email including headers, HTML body, and all attachments combined.

MIME encoding defined in RFC 2045 wraps Base64 output at 76 characters per line when used as Content-Transfer-Encoding. Data URIs in HTML img tags do not require line wrapping. Keep individual Base64 images under 50 KB each to avoid deliverability issues. Use the Base64 Size Calculator to check the encoded size before embedding.

Emails with a total size exceeding 100 KB are more likely to trigger spam filters. Each Base64 image adds to this total. For emails containing multiple images, consider using linked images for large graphics and reserving Base64 for small icons under 5 KB.

When Should You Use Base64 vs CID vs Linked Images?

The choice between Base64, CID, and linked images depends on the email context, recipient client, and image size. Each method serves a different use case based on these factors.

Use Base64 for: small icons (under 5 KB) in automated notifications sent to known clients, self-contained HTML reports that must render offline, and single-file email templates where external dependencies are not acceptable.

Use CID attachments for: marketing emails with multiple images sent to diverse clients, transactional emails with logos that must display in Gmail and Outlook, and emails where image visibility is critical to the message.

Use linked images for: newsletters with large hero images, emails where tracking open rates via image pixel loading is needed, and campaigns where minimizing email size improves deliverability.

For a broader comparison of Base64 versus external file delivery, see Base64 vs Binary. To understand how data URIs work beyond the email context, read the Data URI Guide.

How Does MIME Encoding Handle Images in Email?

MIME (Multipurpose Internet Mail Extensions) defined in RFC 2045 uses Base64 as one of its Content-Transfer-Encoding values. Each email attachment is a separate MIME part with headers specifying the content type, encoding method, and optional Content-ID for CID references.

--boundary_string
Content-Type: image/png
Content-Transfer-Encoding: base64
Content-ID: <logo@example.com>

iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJ
AAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5E
rkJggg==
--boundary_string--

The MIME boundary string separates each part. The Content-Transfer-Encoding: base64 header tells the email client to decode the body of that part using Base64. The Content-ID header assigns an identifier that the HTML body can reference with <img src="cid:logo@example.com">. For a broader explanation of Base64 encoding fundamentals, see What is Base64. To convert images for email embedding, use the Base64 Image Encoder or generate complete embed code with the Embed Code Generator.

Understanding MIME structure is relevant when debugging email rendering issues. If a CID image does not display, check that the Content-ID value matches the cid: reference in the HTML body. If a Base64 image does not render, verify the data URI prefix includes the correct MIME type. The Base64 to PNG Converter can decode and preview Base64 image data to confirm it is valid.

Frequently Asked Questions

Does Gmail support Base64 images?

No. Gmail strips data URI images from incoming emails on both web and Android clients. Images embedded as Base64 data URIs in img src attributes are removed during Gmail's HTML sanitization. Use CID attachments or linked images hosted on a web server for Gmail recipients. This applies to both personal Gmail and Google Workspace accounts.

What is the maximum email size with Base64 images?

Most email providers limit total message size to 25-35 MB. Gmail allows 25 MB, Outlook allows 20 MB, and Yahoo Mail allows 25 MB. Base64 encoding adds 33% overhead, so a 10 MB image becomes approximately 13.3 MB of Base64 text. The total includes the HTML body, headers, and all MIME parts. Keep Base64 images under 50 KB each and total email size under 100 KB for reliable delivery.

Should I use Base64 or CID for email images?

CID (Content-ID) attachments have broader email client support. CID images display in Gmail, Outlook, Apple Mail, and most desktop clients. Base64 data URIs work reliably only in Apple Mail, iOS Mail, and Thunderbird. Use CID for marketing emails targeting diverse clients. Use Base64 only when you control the recipient's email client and need self-contained HTML without separate attachments.

Does Base64 affect email deliverability?

Large Base64 images increase total email size, which can trigger spam filters and slow delivery. Emails exceeding 100 KB total size face higher spam classification rates. Multiple large Base64 images can push an email into the megabyte range, increasing bounce rates and delivery delays. Keep images small, compress before encoding, and use the Base64 Size Calculator to check sizes before embedding.

Can I embed animated GIFs as Base64 in emails?

Yes, animated GIFs can be embedded as Base64 data URIs in clients that support inline Base64, such as Apple Mail and Thunderbird. The animation plays normally when rendered. However, animated GIF file sizes increase by 33% after Base64 encoding. A 500 KB animated GIF becomes approximately 667 KB of Base64 text. For large animations, use linked images hosted externally to keep email size manageable.