Tabwrench tools Small tools that run in your browser. No sign-up, no upload.
Tools / Encode / decode / Image to Base64

Image to Base64

Choose an image file to get its Base64 string or a complete data: URI, plus the HTML and CSS lines that use it. The file is read by your browser and is not uploaded.

Runs in your browser. Nothing you paste leaves this page.
Options
Examples:

Use this often? Add the page to your home screen or bookmarks from the browser menu. It opens straight to the tool.

How to use the result

Click “Choose file”, keep “As data: URI” ticked, and copy the output. A data URI can go anywhere a normal image address can.

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

.icon { background-image: url(data:image/png;base64,iVBORw0KGgo...); }

{ "avatar": "iVBORw0KGgo..." }   // untick the option for a bare string

When embedding an image is worth it

Good fitPoor fit
Icons and small logos of a few kilobytesPhotos and anything above about 10 KB
HTML emails and single-file documents that must work offlineImages reused on many pages, which a browser would otherwise cache once
Sending an image inside JSON to an APIPages where load speed matters and the HTML is already large

Base64 makes the data about 33% larger, and an embedded image cannot be cached separately from the page that contains it. The size line under the tool shows the exact increase for your file.

Questions

Is my image uploaded?

No. The browser reads the file from your disk and converts it in memory.

Which MIME type is written into the data URI?

The type your system reports for the file, or the type recognised from the file's first bytes when none is reported.

Can I embed an SVG this way?

Yes, though for SVG a URL-encoded data URI is usually shorter than Base64, because SVG is already text.

Related tools