Map Extract
Free tool

Convert an image to base64

Choose a PNG, JPEG, GIF, WebP or SVG and get it as text you can paste straight into HTML, CSS or a JSON payload. The page tells you how much bigger the text is than the file, so you can decide whether embedding is worth it.

Runs in your browser. Nothing you enter is uploaded.

Converting an image

  1. Choose the image

    Pick a file from your device. A small preview appears with its name, type and size in bytes.

  2. Pick the output format

    Data URI (ready for an src attribute), Base64 only (for APIs and JSON), CSS background (a complete background-image rule) or HTML img (a ready tag with an empty alt for you to fill in).

  3. Check the size line

    The note shows the original bytes, the length of the text and the base64 size as a percentage of the original. Expect roughly a third more.

  4. Copy the result

    Use the copy button on the output box. For the HTML version, add meaningful alt text before you publish.

Example: a tiny brand colour swatch for an email signature

A design studio (fictional) wants a 16 by 16 pixel square in its brand green beside the name in a plain HTML signature, without hosting a separate file. The PNG is 79 bytes; as base64 it becomes 108 characters, 137% of the original, and 130 characters once the data URI prefix is added.

For an image this small the increase does not matter. For a photo or a full logo it would, which is why the tool warns you once a file passes about 100 KB.

Input
swatch.png, image/png, 79 bytes   Format: Data URI
Result
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAFklEQVR42mOQt9IhCTGMahjVMHw1AACp9YUBBN2QwAAAAABJRU5ErkJggg==

79 bytes → 130 characters (137% of the original size)

When embedding helps and when it hurts

Embedding makes sense for very small images that must travel with the code: an icon in a single-file HTML report, a placeholder in a JSON API request, a background pattern in a stylesheet you hand to a client. There is no separate file to forget, upload or lose.

It works against you for anything larger. Base64 text is about a third bigger than the file, browsers cannot cache it separately, and the whole page has to download before the image can show. Many email programs also block or strip embedded images, so for newsletters and outreach emails a normally hosted image is the safer choice.

  • Good fits: icons, small logos in internal documents, test fixtures, one-file HTML exports.
  • Poor fits: photos, hero images, anything reused across many pages, images in marketing email.

Questions people ask

How do I use a base64 image in HTML?

Choose the Data URI or HTML img format and paste the result into the src attribute of an img tag, or use the complete tag the tool gives you. The browser decodes the text and shows the image without fetching a file. Remember to replace the empty alt attribute with a short description.

Why is the base64 version bigger than the image?

Base64 represents every three bytes of the file with four text characters, so the text is about 33% larger, plus the short data URI prefix. The tool shows the exact percentage for your file. Compressing or resizing the image before converting it is the best way to keep the result small.

Do embedded images work in emails?

Support is patchy. Some mail apps display data URI images, others block them, and some strip them altogether. Gmail in particular does not reliably show them. For outreach or newsletters, host the image and link to it, or attach it, and test in the main mail apps before sending.

Can I turn base64 back into an image?

Yes, with the base64 to image tool on this site. Paste a data URI or raw base64 and it shows the picture and lets you download it as a file, which is handy for pulling an image out of an exported HTML page or an API response.

Where your data goes

The image is read and converted in your browser. It is not uploaded to Map Extract or anywhere else, and the text result exists only on this page until you copy it.

Checked against the tool on

Top