Image to Base64 creates a text representation of an image for a MIME attachment, but the Base64 string alone is not a complete email attachment.

Use the Image to Base64 Converter to turn one local PNG, JPEG, GIF, or WebP file into either plain Base64 for an attachment workflow or a complete data URL for inline HTML. The file is processed in your browser and is not uploaded to Lizely or sent to an external conversion service.

image to base64 for email attachment
Image to Base64 for Email Attachment: MIME Steps

What Base64 changes for an email attachment

Base64 converts the image's binary bytes into text that can be carried inside an email's MIME structure. It does not compress the image, reduce its dimensions, remove metadata, or encrypt its contents. The encoded value is also roughly one third larger than the original file before any data URL prefix is added.

A downloadable attachment normally needs more than the encoded string. The email system must also create the MIME type, transfer encoding, disposition, filename, and message boundaries. An email client, integration, or API that explicitly accepts Base64 attachment content can handle those fields for you. A raw MIME editor gives you direct control but requires more careful setup.

The encoding follows the canonical alphabet and padding rules defined by RFC 4648. When you need a MIME type, use the format detected from the validated file bytes rather than trusting the original filename extension.

Convert the image and set up the email attachment

Follow this workflow for a PNG, JPEG, GIF, or WebP image that you want to send as a downloadable attachment:

  1. Choose one local image. Make sure it is a complete PNG, JPEG, GIF, or WebP file that opens normally. SVG, AVIF, HEIC, BMP, TIFF, PDF, and arbitrary text are outside the converter's supported formats, even when another application labels them as images.
  2. Open the converter and select plain Base64. Plain Base64 is the appropriate output for an email client or API that will place the value in a MIME attachment. Choose the data URL mode only when the image will be embedded directly in HTML.
  3. Run the conversion and inspect the result. Confirm the detected byte format, decoded dimensions, file size, and preview before copying anything. A renamed or mislabeled file may have a different detected format from its extension; for example, PNG bytes renamed with a .jpg extension are still detected as PNG.
  4. Copy the complete output. Do not truncate the string or replace characters. If the browser blocks automatic copying, the visible output remains available for manual selection and copying.
  5. Send the Base64 value to your email system. For a client or API with a Base64 attachment field, provide the copied string, the detected MIME type, and the desired filename separately. For a raw MIME workflow, the relevant part follows this pattern:
    • Content-Type: the detected type, such as image/png or image/jpeg.
    • Content-Transfer-Encoding: base64
    • Content-Disposition: attachment; filename="photo.png"
    • Body: the complete Base64 value copied from the converter.
    The email builder or raw MIME editor supplies the remaining envelope and boundaries. If the interface accepts only file uploads, pasting Base64 will not create an attachment; use the original file or a service that supports Base64 attachment content.
  6. Send a test message. Confirm that the attachment downloads, opens as the expected image type, and has the intended filename before using the encoding in a campaign or automated workflow.

Choose plain Base64 or a data URL

The correct output depends on whether the image should travel as a downloadable attachment or appear inside the message body.

Output Best email use What to provide Main caution
Plain Base64 Downloadable MIME attachment The encoded string plus the detected MIME type and filename It does not create a MIME part or display inline by itself
Image data URL Inline image in HTML The complete data URL, including its prefix and payload Email-client support for inline data URLs varies

For a standard file attachment, plain Base64 is normally the clearer choice. A data URL combines the MIME type and payload in one string, making it useful as the source of an inline image in an HTML email. In data URL mode, the prefix is derived from the verified bytes rather than the filename. A PNG that was incorrectly named photo.jpg will therefore still produce a data:image/png;base64 prefix.

Do not paste a data URL into a field that explicitly requests raw attachment Base64 unless the email integration documents that format. The two outputs are related, but they serve different parts of the message.

Respect the converter's exact limits

The converter enforces input, decoded-image, and output boundaries so that it either produces a complete result or reports an explicit error without leaving a partial value.

Limit Exact rule Practical effect
Input file size 5 MiB, or 5,242,880 bytes The exact boundary is accepted; one byte beyond it is rejected before the file body is read, and the actual buffer length is checked again afterward
Decoded edge length 20,000 pixels maximum per edge Exact limits are accepted, while an excessive width or height is rejected
Decoded pixel area 40,000,000 pixels maximum A compressed image with an excessive decoded width multiplied by height is rejected
Plain Base64 length 6,990,508 characters maximum The limit corresponds to the largest accepted input byte budget
Data URL length 6,990,531 characters maximum, including the prefix The exact boundary is accepted and the next character is rejected

Structural validation comes first: the converter checks the complete PNG, JPEG, GIF, or WebP container, then requires the browser to decode the image and report positive dimensions. A truncated file or a corrupt payload that merely resembles a supported header does not produce a successful result.

If a file is too large or decodes to too many pixels, optimize or resize the original before encoding it. Because the converter preserves the validated bytes, it will not silently recompress the image, flatten transparency, select one frame from an animation, remove metadata, or optimize the payload for you.

Avoid broken attachment hand-offs

  • Do not trust the extension for MIME selection. The converter ignores a misleading filename extension, file-picker filter, or operating-system MIME declaration. Use the byte format it confirms, especially when setting the attachment's Content-Type field.
  • Do not shorten the encoded value. A missing final group or omitted padding can make the payload invalid. Copy the complete output exactly as shown.
  • Do not confuse an inline image with an attachment. A data URL in an HTML image source asks the client to render the image inline. A downloadable file normally uses a MIME part with attachment disposition.
  • Remember that Base64 is not encryption. Anyone or any system that receives the encoded string can decode it. Once you paste it into an email service, it is transmitted according to that service's privacy and security controls.
  • Expect animation support to depend on the recipient. The original animated GIF or WebP bytes remain intact, but the email client must support the format for the animation to render as intended.
  • Keep the original until the test passes. Successful decoding confirms technical readability, not that a file is safe, authentic, accessible, or free of concealed data.

Test the message before sending it

Send a small test to an address you control and inspect the received message. For an attachment, verify its filename, MIME type, download behavior, and rendered contents. For an inline data URL, check whether the image appears in the message body and whether the recipient's client displays it consistently.

Keep the original file and the final encoded string together only as long as your workflow requires. The local conversion protects the source during encoding, but the copied Base64 value still needs to be transferred into the email system and handled according to that system's security practices.

If you're weighing options, Image to PDF for Email Attachment: Prepare One File covers this in detail.