Image to Base64

Convert images to base64 data URIs for embedding directly in HTML, CSS, or JSON. Eliminate HTTP requests for small images.

100% client-side No signup Free forever

Drag & drop an image here or browse

Supports: JPG, PNG, GIF, WebP, SVG, ICO
// how to use

How to Use Image to Base64

How to Convert Images to Base64

  1. Upload image: Select a JPEG, PNG, GIF, WebP, or SVG file.
  2. Wait for encoding: The image is converted instantly in your browser.
  3. Choose output format: Select Data URI, raw Base64, CSS, or HTML output.
  4. Copy result: Copy the encoded string to your clipboard.
  5. Paste in code: Use directly in your HTML, CSS, or JavaScript.

Example Outputs

HTML img tag:

<img src="data:image/png;base64,iVBORw0KGgo..." alt="Embedded image">

CSS background:

.icon { background-image: url(data:image/png;base64,iVBORw0KGgo...); }
// features

Features

  • Convert JPEG, PNG, GIF, WebP, SVG to Base64
  • Generate complete Data URI
  • Output as HTML img tag
  • Output as CSS background-image
  • Raw Base64 string option
  • Show original file size
  • Show Base64 string size
  • One-click copy to clipboard
  • Preview embedded image
  • Client-side processing (no upload)
  • No file size limit
  • Free with no registration
// about

About Image to Base64

Every image on a webpage typically requires a separate HTTP request. For small images, the request overhead exceeds the image size itself. Base64 encoding embeds images directly in HTML or CSS, eliminating these requests and potentially improving performance.

How Base64 Encoding Works

Base64 converts binary image data to ASCII text:

  • Encoding: Binary bytes mapped to 64 printable characters
  • Size increase: Encoded data is ~33% larger than original binary
  • Data URI format: data:image/png;base64,iVBORw0KGgo...
  • Browser support: Universal across modern browsers

When to Use Base64 Images

Ideal for: Icons under 2KB, CSS background patterns, single-use images, email HTML templates. Avoid for: Large photos, images used across multiple pages (lose caching benefit), frequently changing images.

Performance Considerations

While base64 eliminates HTTP requests, it increases HTML/CSS file size by 33%. The encoded data also can't be cached separately from the document. For images under ~2KB, the request savings outweigh the size increase. Larger images should remain separate files.

Integration in Development

Use base64 encoding for: embedding critical icons in initial HTML, including images in single-file exports, creating self-contained email templates, and reducing complexity in projects without build tools.

// faq

Frequently Asked Questions

What is Base64 image encoding?
Base64 converts binary image data to text characters. This lets you embed images directly in HTML, CSS, or JSON without separate files. The encoded string starts with "data:image/png;base64," followed by the encoded data, creating a data URI.
Why would I encode images to Base64?
Use cases include: embedding images in CSS backgrounds (no extra HTTP requests), including images in email HTML, storing images in databases or JSON, and encoding images for API transmission. It's useful when you can't or don't want to reference external files.
Does Base64 increase image file size?
Yes, Base64 encoding increases size by approximately 33%. A 10KB image becomes roughly 13KB of text. This trade-off is acceptable for small images (icons, logos) but inefficient for large images. Consider the total page load impact.
How do I use Base64 images in HTML or CSS?
In HTML: <img src="data:image/png;base64,iVBOR...">. In CSS: background-image: url(data:image/png;base64,iVBOR...). Our tool provides ready-to-use code snippets for both. Simply copy and paste into your code.
What image formats work with Base64?
Any image format: PNG, JPEG, GIF, WebP, SVG (including animated GIFs). The format is specified in the data URI prefix (data:image/jpeg;base64,). Make sure to use the correct MIME type for the image format you're encoding.
Can I decode Base64 back to an image?
Yes! Paste a Base64 string (with or without the data URI prefix) and we'll convert it back to a downloadable image file. Useful for extracting embedded images from code or converting stored Base64 data back to usable images.