</>DevTools

IMGImage to Base64

Convert images to Base64 data URIs

Image to Base64 Conversion Complete Guide

Image to Base64 Converter transforms PNG, JPG, GIF, WebP, and other images into Base64-encoded Data URI strings. Use them to embed images directly in HTML <img> tags or CSS background-image without external files, or to include image data inside JSON / API payloads. All conversion runs in your browser — images are never uploaded to a server.

Understanding Base64 Image Embedding

The Data URI Format

The conversion output is a Data URI in the following format:

data:[MIME type];base64,[Base64-encoded data]

// Example
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...

Using in HTML and CSS

<!-- HTML img tag -->
<img src="data:image/png;base64,iVBOR..." alt="icon" width="32" />

/* CSS background-image */
.icon {
  background-image: url('data:image/png;base64,iVBOR...');
  width: 32px;
  height: 32px;
}

/* Inline SVG */
background-image: url("data:image/svg+xml,%3Csvg...");

The 33% Size Increase Trade-off

Base64 encodes every 3 bytes as 4 ASCII characters, resulting in approximately a 33% size increase. Small icons (1–5 KB) and SVGs benefit from inline embedding by eliminating HTTP requests. For large background images, serving as an external file yields better loading performance.

When to Use Base64

  • Favicons / small icons: Eliminate HTTP requests
  • HTML email: Inline images in environments that block external images
  • Offline / PWA: Display images without network access
  • API payloads: Include image data inside JSON
  • Canvas / WebGL: Load images via data URL

Practical Example: Inline Email Images

HTML email clients often block external image loading. Convert your logo or banner to Base64 and embed it as <img src="data:..."> — the image displays without any external resource request.

🔗Related Tools🧰 Misc