🖼️ Image to Base64 Converter — Generate Data URIs

Convert any image (PNG, JPG, GIF, WebP, SVG) to a Base64 data URI. Preview the image, copy the data URI for use in CSS or HTML. 100% browser-based.

Drop your image file and instantly get its Base64-encoded data URI. Copy the full data:image/... string to embed the image directly in your CSS background-image or HTML img src — no separate file needed, no server request.

🖼️
Drop an image here or
PNG, JPG, GIF, WebP, SVG supported

How to Use

1

Upload your image

Click the upload area or drag and drop any PNG, JPG, GIF, WebP, or SVG file.

2

Choose output format

Toggle between full Data URI (data:image/png;base64,...) and raw Base64 string only.

3

Copy the result

Click Copy to clipboard. Use the data URI directly in your CSS background-image or HTML src attribute.

Frequently Asked Questions

What is a Base64 image data URI? +
A data URI embeds the image directly in your HTML or CSS as text: data:image/png;base64,iVBORw0KGgo.... This eliminates a separate HTTP request for the image file, useful for small icons, backgrounds, and email templates.
What image formats are supported? +
PNG, JPG/JPEG, GIF, WebP, SVG, BMP, ICO, and most common image formats are supported. The MIME type is automatically detected from the file and included in the data URI.
How large will the Base64 output be? +
Base64 encoding increases file size by approximately 33%. A 100KB image becomes roughly 133KB as Base64 text. For images over 50KB, linking to the file is usually better for performance than embedding.
How do I use this in CSS? +
Copy the full data URI and use it as: background-image: url("data:image/png;base64,..."); In HTML: <img src="data:image/png;base64,...">. For email templates, inline data URIs ensure images display without external loading.
Is my image uploaded to a server? +
No. The entire conversion runs in your browser using the FileReader API. Your image never leaves your device and is never sent anywhere.


Complete Guide: Image to Base64 Converter

The Image to Base64 Converter transforms image files into Base64-encoded data URIs that you can embed directly in HTML, CSS, or JavaScript — eliminating the need for a separate HTTP request to load the image. It supports JPEG, PNG, GIF, WebP, SVG, and ICO formats.

Understanding the Data URI Format

A data URI follows this structure:

data:[mimetype];base64,[base64-encoded-data]

For a PNG image, that looks like:

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

The browser treats this string exactly like a URL pointing to an external file, but the entire image data is embedded inline. No network request is made.

Embedding in HTML

Replace a normal src attribute value with the data URI:

<img
  src="data:image/png;base64,iVBORw0KGgo..."
  alt="Company logo"
  width="120"
  height="40"
>

This is particularly useful in email HTML, where external images are often blocked by default by email clients. Inline data URIs bypass that restriction, though some older email clients have size limits on inline data.

Embedding in CSS

Data URIs work as values for background-image:

.logo {
  background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxu...");
  background-size: contain;
  background-repeat: no-repeat;
}

This technique is common for small decorative icons in UI component libraries where every HTTP request saved improves perceived performance on low-latency connections.

Size Overhead: The ~33% Rule

Base64 encoding converts every 3 bytes of binary data into 4 ASCII characters, which increases the encoded size by approximately 33%. A 10 KB PNG becomes roughly 13.3 KB as a Base64 string. When served over HTTP with gzip or Brotli compression, much of this overhead is recovered because Base64 output is highly compressible. However, the decoded in-memory size is still larger, and browsers cannot cache inline data URIs separately from the HTML or CSS document they are embedded in.

When to Use Data URIs vs External URLs

The single-page trade-off is important: a data URI eliminates one HTTP request but increases HTML/CSS payload size, which affects time-to-first-byte parsing. For pages with many large inline images, this degrades initial load performance.

SVG: The Special Case

SVG files can be embedded without Base64 encoding, because SVG is XML text. You can use URL-encoded SVG directly:

background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'...");

URL-encoded SVG is slightly smaller than Base64-encoded SVG and is more readable during debugging. It also allows you to modify the SVG inline — for example, changing a fill colour via CSS custom properties — which is impossible once the SVG is Base64-encoded as an opaque blob.

Embedding in Email HTML

Most email clients — including Gmail and Outlook — block externally loaded images by default. Embedding small images as Base64 data URIs guarantees they display without requiring the recipient to click "load images". Keep total email size under 100 KB including all inline images to avoid deliverability issues with spam filters.

Related Tools

For general text and string encoding tasks, see the Base64 Encoder. Before embedding large images, reduce their file size with the Image Compressor to keep the Base64 output manageable.

🧰 50+ Tools