Skip to content
Devtoolry

Image to Base64

Convert images to Base64 online: get a data URI, raw Base64, an <img> tag or CSS background for PNG, JPEG, SVG, WebP or GIF. Files stay in your browser.

Runs in your browser · Nothing uploadedFree · No sign-up

Something not working, or missing a feature? Send feedback

About the Image to Base64

The Image to Base64 converter turns a PNG, JPEG, SVG, WebP, GIF or AVIF file into Base64 text you can embed directly in HTML, CSS, JSON or Markdown. You get a ready-made data URI, the raw Base64, an <img> tag and a CSS background rule, and the image never leaves your browser.

Images are processed in your browser with its built-in codecs, so your photos and screenshots are never uploaded.

How to use the Image to Base64

  1. Drop an image onto the box, paste it from the clipboard, or choose a file.
  2. Pick the output you need: data URI, raw Base64, <img> tag, CSS background or Markdown.
  3. Copy the result into your code. The size line shows how much bigger the Base64 version is.

Where it works well

  • Small icons and images to inline in HTML, CSS, JSON or email templates.

Where it struggles

  • Large photos: Base64 is about a third bigger than the file and cannot be cached separately, so link to the file instead.

Common mistakes

  • Inlining large images. A 200 KB photo becomes about 270 KB of text inside your HTML or CSS, delays rendering and is downloaded again with every page. Keep data URIs for small icons.
  • Forgetting the prefix. Raw Base64 is not a URL. In src or url() you need the full data URI, including data:image/png;base64, at the start.

Works well with the Image to Base64

Frequently asked questions

When should I inline an image as Base64?

For very small images, such as icons under a few kilobytes, in emails, single-file HTML documents or CSS that must not make extra requests. Larger images are better served as files, because Base64 is about 33% bigger and cannot be cached separately.

What is a data URI?

A URL that contains the file itself: data:image/png;base64, followed by the Base64 data. Browsers accept it anywhere an image URL is allowed, such as the src of an <img> or url() in CSS.

Is my image uploaded?

No. The file is read and encoded in your browser with the FileReader API; nothing is sent to a server.