Image to Base64 Encoder

Convert images to base64 data URIs for CSS, HTML, or JSON embedding.

Ad placeholder (leaderboard)

A base64 data URI lets you embed an image directly inside your HTML, CSS, or a JSON payload, so the browser renders it without a separate file download. This free encoder converts an image to that inline form in your browser and shows the size overhead so you can decide whether inlining is worthwhile.

How it works

The tool reads your selected image with FileReader.readAsDataURL, which returns a string of the form data:image/png;base64,<payload>. The data: scheme tells the browser the bytes follow inline; the MIME type identifies the format; and ;base64 marks the payload encoding. Because base64 maps every 3 bytes to 4 ASCII characters, the resulting string is about a third larger than the original file — the tool computes and displays this overhead.

Tips and example

Inlining is a trade-off: you save one HTTP round-trip but lose the ability to cache the image separately and you bloat the document that references it. Reserve it for tiny, ubiquitous assets. A CSS example looks like:

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

For larger photos, keep them as standalone files. The HTML output format wraps the data URI in an <img> tag with the original file name as alt text — edit the alt text to something descriptive before shipping.

Ad placeholder (rectangle)