Friday, November 6, 2026 · Asia/KarachiFree tools · No signup · Runs in your browser

Image to Base64

bars-32x16.png is 119 bytes. The data URL starts with data:image/png;base64, and then the standard base64 of those bytes. The download is a text file of that URL, not a new image. bars-32x16.jpg starts with data:image/jpeg;base64, and the MIME follows the file type the browser recorded. Nothing is resized. A 119-byte PNG stays 119 bytes inside the URL, plus the prefix.

New

The data URL is the file you chose, including its bytes. Nothing is resized or recompressed. A large photo makes a long string.

How to use

  1. Encode bars-32x16.png when you want a data:image/png URL.
  2. Encode bars-32x16.jpg when you want a data:image/jpeg URL.
  3. Copy the text download. It is not a new picture file.

Formula / how it works

bars-32x16.png is 119 bytes. The data URL starts with data:image/png;base64, and then the standard base64 of those bytes. The download is a text file of that URL, not a new image. bars-32x16.jpg starts with data:image/jpeg;base64, and the MIME follows the file type the browser recorded. Nothing is resized. A 119-byte PNG stays 119 bytes inside the URL, plus the prefix.

The encoder walks the bytes in chunks and uses the platform base64. It is not a hex dump and not a hash. You can paste the URL into an img src, a CSS url, or a JSON string. A quote inside a JSON string still needs escaping. This page does not wrap the URL in quotes for you, because the next tool might want the raw URL.

Large photos are the limit. A 4 MB JPEG becomes a data URL about a third larger. The page will build it, and the tab can get heavy. That is why the sample is a 32 by 16 image. If the string is for an email template, consider a hosted file instead. The page does not upload the image anywhere in order to host it.

The MIME falls back to the extension when the picker leaves the type empty. jpg is written as image/jpeg. A file that is not an image still gets encoded, because base64 does not care, but the control asks for an image so the MIME is one you can drop into an img tag. Decoding the sample PNG from the URL returns 32 by 16 again. That round trip is the check that the alphabet was not truncated.

Use the JPG to PDF page when you need a page, not a string. Use this page when a config file, a sample string in your own notes, or an HTML draft needs the bytes inline. The PNG sample is 119 bytes before the data URL prefix is counted.

Decoding the PNG data URL returns the same 32 by 16 image the button read. The 119 raw bytes become a longer string because base64 uses four characters for every three bytes, plus the data:image/png;base64, prefix. The JPEG sample uses image/jpeg in that prefix.

When you need a page instead of a string, use JPG to PDF. PNG to JPG changes the bytes before you encode them.

Worked examples

PNG data URL

Inputs: b64-f: bars-32x16.png

On this page, take bars-32x16.png and press Encode. Save the text, not a renamed image.

Result: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAQCAIAAAD4YuoOAAAACXBIWXMAAAPoAAAD6AG1e1JrAA… Bytes: 119. The data URL is the file you chose. Nothing is resized, and the download is that same text.

JPEG data URL

Inputs: b64-f: bars-32x16.jpg

On this page, take bars-32x16.jpg and press Encode. Save the text, not a renamed image.

Result: data:image/jpeg;base64,/9j/2wBDAAIBAQEBAQIBAQECAgICAgQDAgICAgUEBAMEBgUGBgYFBgYGBwkIBgcJBwYGCAsIC… Bytes: 275. The data URL is the file you chose. Nothing is resized, and the download is that same text.

Use cases

  • Pasting the 119-byte PNG into an HTML draft as a data URL.
  • Checking the JPEG URL starts with data:image/jpeg;base64.
  • Avoiding a resize that would change the bytes.
  • Keeping a large photo out of a data URL when the tab would groan.

Tips & limitations

  • The PNG sample is 119 bytes before the prefix.
  • Base64 is longer than the raw file by about a third.
  • The page does not add JSON quotes.
  • jpg is labelled image/jpeg even though the extension is jpg.

FAQ

How long is the PNG sample before encoding?

119 bytes. The data URL adds the data:image/png;base64, prefix and the base64 alphabet.

Does the encoder resize?

No. A 32 by 16 PNG stays 32 by 16 when you decode the URL.

Why is the download a text file?

The payload is the URL string. Saving it as a .png would corrupt it.

Are quotes added for JSON?

No. Add them yourself if the next file is JSON.

What MIME does the JPEG sample get?

image/jpeg, so the URL starts with data:image/jpeg;base64.

Should a 4 MB photo become a data URL?

Usually no. The string is about a third larger and the tab holds it. The sample is small on purpose.

119 bytes is bars-32x16.png. A camera JPEG will produce a much longer URL, and this page will still build it.