Image to Base64 Converter

Convert images to Base64 strings, Data URIs, CSS background-image, HTML img tags, and Markdown. Also decode Base64 back to images. Everything runs 100% in your browser.

100% Client-Side No Upload Multiple Formats Drag & Drop

Upload Image

Drag and drop an image or click to select. Supports JPG, PNG, GIF, SVG, WebP, BMP, and ICO (max 5 MB).

Drop your image here

or click to browse files

JPG, PNG, GIF, SVG, WebP, BMP, ICO

Image preview
Original
--
Base64
--

About Base64 Image Encoding

Base64 encoding converts binary image data into an ASCII string representation. This allows images to be embedded directly into HTML, CSS, or JavaScript files without requiring separate HTTP requests. The encoded string uses only characters A-Z, a-z, 0-9, +, and /, making it safe for embedding in text-based formats.

When to Use Base64 Inline Images

  • Small icons and logos (under 2-5 KB) where eliminating an HTTP request is beneficial
  • Email HTML templates where external images may be blocked by email clients
  • CSS sprites replacement for small decorative images and UI elements
  • Single-file HTML documents that need to be self-contained and portable
  • Data URIs in SVG for embedding raster images inside SVG files

Performance Tradeoffs

Base64 encoding increases file size by approximately 33% compared to the original binary. A 10 KB image becomes roughly 13.3 KB when Base64 encoded. For small images (under 2-5 KB), the savings from eliminating an HTTP request often outweigh the size increase. For larger images, it is generally better to serve them as separate files so they can be cached independently by the browser.

Base64 images embedded in CSS or HTML cannot be cached separately from the containing document. If the same image appears on multiple pages, each page must include the full Base64 string. Modern HTTP/2 multiplexing has also reduced the overhead of multiple small requests, making inline images less advantageous than they once were.

Data URI Format

A Data URI follows the format: data:[mediatype][;base64],data. For example, data:image/png;base64,iVBORw0KGgo... embeds a PNG image directly. This format is supported by all modern browsers and can be used in <img> src attributes, CSS background-image properties, and other contexts that accept URLs.

Supported Image Formats

  • JPEG / JPG — Lossy compression, best for photographs (image/jpeg)
  • PNG — Lossless compression with transparency support (image/png)
  • GIF — Supports animation and simple transparency (image/gif)
  • SVG — Vector format, scales to any size (image/svg+xml)
  • WebP — Modern format with excellent compression (image/webp)
  • BMP — Uncompressed bitmap (image/bmp)
  • ICO — Icon format used for favicons (image/x-icon)

Best Practices

Keep Base64-encoded images under 5 KB for optimal performance. For larger assets, use standard image files served over HTTP/2 with proper caching headers. When embedding in CSS, consider that the stylesheet must be fully downloaded before any Base64 images render, which can delay perceived page load. Always compress images before encoding to minimize the Base64 output size.