Skip to content
helpyself

Image to Base64 Converter

Local only — nothing is uploaded unless you save or share it.

Convert an image to Base64: the data URI, an HTML img tag and CSS, ready to paste. And back again.

  1. Drop in one or more images, or paste a screenshot
  2. Copy the data URI, the HTML img tag, the CSS line or the raw Base64
  3. To go back, paste a data URI or Base64 into the second box and download the image

Image to Base64

Base64 to image

Paste a data URI or plain Base64 to see the image and download it.

Save this tool

Keep Image to Base64 Converter handy

Bookmark it
Embed

Put Image to Base64 Converter on your website

Paste this into your page. It shows the tool, free, with a link back to it.

About this tool

Base64 writes a file's bytes as plain text, and a data URI is that text behind a short prefix such as data:image/png;base64, so an image can live inside an HTML page, a stylesheet, an email template or a JSON payload instead of in a file of its own. This image to Base64 converter does the job in one step: drop in a PNG, JPG, GIF, WebP, SVG, AVIF, BMP or ICO, or several at once, and each one comes back as four things to paste, each with its own Copy button: the data URI, an HTML img tag with the width and height already filled in, a CSS background-image line, and the raw Base64 on its own. So it works as a PNG to Base64 or SVG to Base64 converter as much as for photos. The format is read from the file's own bytes rather than its name, so a renamed JPEG still gets image/jpeg. Base64 is about a third bigger than the file it encodes, and the page shows both sizes. That is fine for an icon or a small logo; for a large photo it usually is not, because an inlined image cannot be cached on its own and makes the page around it heavier, and the page says so. It also works backwards: paste a data URI or plain Base64 into the second box to see the image, its real type and size, and download it as a file. Everything happens on your device, so nothing is uploaded.

Frequently asked questions

How do I convert an image to Base64?

Drop the image on this page. It is encoded at once, and you get the data URI, an HTML img tag, a CSS background-image line and the plain Base64, each with its own Copy button. Copy all takes every snippet of every image, and Download saves them as a .txt file.

What is a data URI?

A data URI is a file written out as a URL: data:image/png;base64, followed by the Base64 of the file's bytes. Anywhere a browser accepts an image address, in an img src, a CSS url() or an email, it accepts a data URI instead, so the image travels inside the code rather than as a separate file.

Why is the Base64 bigger than my image?

Base64 uses four characters for every three bytes, so the text is about 33% larger than the file, and the page shows both sizes. That overhead is the reason to keep data URIs for small things such as icons, logos and simple SVGs. A large photo is usually better served as an ordinary file, which the browser can cache and load on its own.

Can I turn Base64 back into an image?

Yes. Paste a data URI or plain Base64 into the Base64 to image box and the picture appears straight away, with its format, pixel size and file size, and a Download button. The type is read from the bytes, so if a data URI says PNG but holds a JPEG, you are told and the file downloads as .jpg.

Which image formats can I convert to Base64?

PNG, JPG, GIF, WebP, SVG, AVIF, BMP and ICO, the formats a browser shows from a data URI. TIFF and HEIC are not accepted, because most browsers cannot display them inline; convert them to JPG or PNG first.

Is my image uploaded?

No. The encoding and decoding run in your browser, and the image never leaves your device.

Help improve this tool

Found a bug, want a change, or need a tool we don't have?

/image-to-base64

↑↓ to move · Enter to open · Esc to close