Image to Base64 Converter

Drop an image and get a Base64 data URI you can paste straight into HTML or CSS. Everything runs in your browser — the file is never uploaded.

Drop an image here or click to browse
PNG · JPG · GIF · SVG · WebP · AVIF
Preview of the converted image
DATA URI
Waiting for an image

How to convert an image to Base64

Drag any image onto the drop zone above (or click to browse). The tool reads it locally with the browser's FileReader API and produces a data URI — a string of the form data:image/png;base64,iVBORw0KGgo… that embeds the whole image inline. Click Copy, then paste it where you need it. Use the Raw Base64 toggle if you want only the encoded payload without the data: prefix.

Using the data URI in HTML and CSS

In HTML, drop it into an <img> src:

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..." alt="logo">

In CSS, use it as a background-image:

.logo {
  background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0i...");
}

When should you inline an image as Base64?

Inlining removes one HTTP request, which is a real win for tiny, critical assets — icons, a small logo in the header, an inline SVG, or a placeholder. The tradeoffs:

Tip: for SVGs, plain URL-encoding is often smaller than Base64. But Base64 is the universally safe choice when an asset contains characters that break inline markup.

Is this converter private?

Yes. The conversion happens entirely client-side in JavaScript. Your image is read into memory in the browser and encoded locally — it is never sent to a server. You can confirm this by opening DevTools → Network: adding an image fires no upload request.

Frequently asked questions

What image formats are supported?

Any format the browser can read — PNG, JPEG, GIF, SVG, WebP, AVIF, BMP, and ICO. The data URI's MIME type comes from the file itself.

How do I go the other way (Base64 back to an image)?

Use the Base64 to Image tool to decode a data URI or raw Base64 back into a viewable, downloadable image.

Need text, files, or URL-safe Base64?

The main base64.dev tool handles text, files, and URL-safe mode with auto-detect.

Open base64.dev →