P
Privatool
Guide2 min read

Image to Base64 Converter — Embed Images Directly in HTML and CSS

Learn how to convert images to Base64 Data URIs for embedding in HTML, CSS, and JavaScript. Free online converter with multiple output formats.

By Privatool Team·

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 scheme
  • image/png — MIME type
  • ;base64, — encoding indicator
  • iVBOR... — 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

  1. Go to Image to Base64
  2. Upload your image
  3. Select output format (Data URI, HTML <img>, CSS background, etc.)
  4. Copy the result
  5. Paste directly into your code
#image to base64#data uri#embed image html#base64 image#inline image

Try our free tools

All tools run in your browser. Files never leave your device.

Explore free tools →