Image to Base64 & Back · Tutorial

How to embed a small logo in an HTML page or email

6 min readbeginnerUpdated

You want a small logo or icon to appear without linking to a separate image file, for example in a single-file HTML report, an offline page or an HTML email signature. This tutorial converts the image to Base64, inserts it with a ready-made tag, and explains the limits, especially in email clients.

What you need

  • The Image to Base64 & Back converter
  • A small image, ideally a PNG or SVG logo under about 20 KB
  • The HTML file or template you're editing

Steps

  1. Prepare a small image

    Start with the smallest image that looks sharp at the size you'll display it. A logo shown at 120 pixels wide doesn't need a 2,000-pixel source. Resize and compress it first if needed. Smaller images make smaller data URLs.

  2. Convert it

    Open the converter and drop your image onto the box. You'll see a preview with its dimensions, and a note comparing the original size with the encoded size, which is about a third larger.

  3. Write a useful alt text

    Replace the alt text with a short description, such as Harbour Labs logo. It's read by screen readers and shown when images are blocked, which happens often in email.

  4. Copy the HTML snippet

    Press Copy next to HTML <img>. The tag already includes the data URL, your alt text and the width and height, so the layout doesn't jump while the page loads.

    <img src="data:image/png;base64,iVBORw0KGgo…" alt="Harbour Labs logo" width="120" height="40">
  5. Paste it into your page

    Paste the tag where the logo should appear. Open the page in a browser to check it. The image displays with no separate file and no network request.

Try it yourself

Opens the Image to Base64 & Back.

Try it now

Common mistakes

Embedding large photos
A 500 KB photo becomes about 670 KB of text inside your HTML, making every page load slower. Keep embedded images small and use normal image files for anything big.
Relying on data URLs in every email client
Several popular email clients block or strip data URL images, especially in received mail. For email campaigns, an image hosted on your website, or attached and referenced with a content ID, is more reliable.
Forgetting dark mode
A logo with a transparent background may disappear on dark backgrounds. Test it on both, or add a subtle background to the image.

Next steps

Go back to the Image to Base64 & Back, or keep going with one of these:

FAQ

Can I embed an SVG this way?

Yes. SVG files are encoded like any other image. For SVG, a URL-encoded data URL can be even smaller than Base64, but Base64 works everywhere.