Image to Base64 converter

Drop a picture and get its Base64 string or a data URI ready to paste into HTML, CSS or JSON. The image stays on your device. Jump to the image converter.

  • Free
  • No sign-up
  • Runs in your browser
image-to-base64

100% private — everything is converted in your browser and nothing is uploaded.

Files and images

Encode a file to Base64

100% private — everything is converted in your browser and nothing is uploaded.

How it works

Drop your image

In the Files and images section, drop a PNG, JPG, GIF, WebP or SVG (up to 100 MB).

Choose the format

Keep the data: prefix for a data URI, or untick it for the raw Base64. Tick URL-safe if you need it.

Copy the code

Copy the result and paste it into your img tag, style sheet or JSON.

How to convert an image to Base64

To convert an image to Base64, drop the picture on the file box in the Files and images section below the text converter. The Base64 string appears right away, with the data: prefix by default so it is a ready-to-use data URI, and you can copy it with one click. The picture is read inside your browser and is never uploaded.

What is an image data URI?

A data URI stores a file directly inside a web address, in the form data:image/png;base64, followed by the Base64 of the file. A browser shows it like a normal image, without making a separate request. This is a complete, valid one: a 1 by 1 red pixel PNG. data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/iZk9HQAAAABJRU5ErkJggg==

How to use it

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/iZk9HQAAAABJRU5ErkJggg==" alt="">

.icon { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/iZk9HQAAAABJRU5ErkJggg=="); }

When Base64 images make sense

  • Tiny icons and placeholders, under about 5 KB, where saving a request is worth more than the extra weight.
  • HTML emails and single-file pages, which must work without any external file.
  • JSON or API payloads that can only carry text, such as sending a profile picture to a service.
  • Prototypes and demos, where you want one file that just works.

When to avoid them

Base64 makes a file about 33% larger and the browser cannot cache the image separately from the page. For large photos, keep normal image files and compress them first. Shrinking the picture before converting, for example with the image compressor, is the easiest way to keep the string short.

Private by design

The conversion runs in your browser. What you type, paste or drop is never uploaded, which matters when the text holds tokens, personal data or internal files.

Frequently asked questions

Which image formats can I convert?
Any file can be converted: PNG, JPG, GIF, WebP, AVIF and SVG all work. The data URI carries the right type automatically.
Is there a size limit?
The file section accepts up to 100 MB, but long Base64 strings are awkward in practice. Keep images that go into code to a few kilobytes.
Can I turn the Base64 back into an image?
Yes. Paste the string, or the whole data URI, into the decode box of the same file section and download the picture.
Is this converter free?
Yes. There is no sign-up and no limit, and it runs in your browser, so nothing you type is sent to a server.
Does it work on a phone?
Yes. It works in any modern mobile browser, and the result updates as you type.