← All free tools Converter tools

Image to Base64

Transform an image file into a Base64 string.

Files stay on your device. Nothing is uploaded.

About this tool

Image to Base64 turns an image file into Base64 text, so it can go straight into HTML, CSS, JSON or an email instead of being a separate file. You get a ready-to-use data URI, or the plain Base64 if you untick the prefix.

How to use Image to Base64

  1. Choose an image, or drop it on the box.
  2. Keep Include the data URI prefix ticked for HTML and CSS, or untick it for plain Base64.
  3. Copy the result. Its length in characters is shown above it.

Using the result

In HTML: <img src="data:image/png;base64,…" alt="…">

In CSS: background-image: url("data:image/png;base64,…");

When it’s a good idea

Base64 is about a third bigger than the file, and browsers can’t cache it separately, so it’s best for small images: icons, a logo in an email signature, a placeholder or an image in a single-file HTML page. For photos and large graphics, a normal image file loads faster. For SVG icons, inlining the SVG code itself is often smaller still.

The image is read in your browser, and nothing is uploaded.

Have a project in mind?

Have a brand or a product to grow?