Image to Base64 Converter

Encode an image as Base64 and copy it as a data URI, an HTML image tag or a CSS background. You can also decode Base64 back into an image.

How to use the Image to Base64 Converter

  1. Choose an image, or drag or paste it in.
  2. Pick the output you need: data URI, raw Base64, HTML img tag or CSS background.
  3. Copy the code or download it as a text file.

What is Base64?

Base64 turns binary data into plain text using 64 safe characters (A–Z, a–z, 0–9, + and /). A data URI wraps that text with the file type so a browser can display it directly:

data:image/png;base64,iVBORw0KGgo…

This lets you embed an image inside an HTML, CSS, JSON or email file instead of linking to a separate file.

When to embed images

  • Small icons and logos, to save a network request.
  • HTML emails and single-file documents.
  • Sending images through APIs that accept only text.

When not to

Base64 makes data about 33% larger and embedded images cannot be cached separately by the browser. For anything bigger than a few kilobytes, a normal image file is faster.

Private by design

The image is opened and processed by your browser on your own device. It is not uploaded to a server, so the tool also works offline once the page has loaded.

Frequently asked questions

How do I convert an image to Base64?

Upload the image and copy the generated string. Choose "Data URI" for use in HTML or CSS, or "Base64 only" for APIs.

Why is the Base64 version larger than the file?

Base64 encodes every 3 bytes as 4 characters, so the result is about one third larger.

How do I use a Base64 image in HTML?

Put the data URI in the src attribute: .