Skip to content
PictureToLink logoPictureToLink
Menu

Image to Base64

Encode an image as Base64 or a data URI with ready-made code snippets, or decode Base64 back to a picture.

Drop an image to encode

PNG, JPG, GIF, WebP, SVG, ICO · up to 10 MB · encoded on your device, nothing is uploaded

How to convert an image to Base64

  1. Drop an image on the box or tap “Choose image”.
  2. Copy the format you need: the full data URI, the Base64 text alone, or a snippet for your page.
  3. Paste it into your code. The image now travels inside the page or file instead of being loaded separately.

What a data URI looks like

Base64 makes a file bigger, so it suits small images. Not sure how big yours is? The image size calculator will tell you.

A data URI has three parts: data:, the file type (for example image/png) followed by ;base64, and after a comma the encoded image. Anywhere a browser accepts an image address, such as an <img src>, a CSS url() or a Markdown image, it accepts a data URI too. The format is defined in RFC 2397, and Base64 itself in RFC 4648. A PNG therefore starts data:image/png;base64,iVBOR and a JPG data:image/jpeg;base64,/9j/. In return for the extra size, the image travels inside the page and needs no separate download.

When Base64 helps, and when it hurts

Base64 earns its place with small icons, a self-contained HTML report, or a picture that has to live inside a JSON or config file. Photos are another matter. The text is about 33% larger than the file and can’t be cached on its own, so every page that carries it gets slower to download and parse. Email is a gamble too.

Past a few kilobytes, an ordinary image URL usually wins. Upload the image to PictureToLink to get a direct link, or read Base64 images vs URLs for a fuller comparison.

Make it small first

Every byte grows by a third, so shrink the image first. Resize it to the size it will be shown at, then compress it. Simple icons are often smaller still as SVG.

Decoding Base64

Got a long string starting with data:image or iVBOR (a PNG) or /9j/ (a JPG)? Switch to “Base64 → Image” and paste it, or go straight to the Base64 to image converter, which opens on that mode. The tool also accepts URL-safe Base64 and ignores line breaks. SVG data isn’t previewed, because SVG files can contain scripts.

Questions and answers

What is a Base64 image?

It is an image file written out as plain text using 64 safe characters. Put inside a data URI, such as data:image/png;base64,…, it can go straight into your code without a separate image file or link.

Why is the Base64 version bigger?

Base64 turns every 3 bytes into 4 characters, so the text is about a third larger than the original file. That’s why it suits icons and logos, not photos.

When should I use a data URI instead of an image link?

Use one for a tiny image that must load with the page, or where you can’t host a file, such as a self-contained HTML report. Anything larger works better as a normal image URL. Browsers cache it separately, and the page stays smaller.

Can I decode Base64 back to an image?

Yes. Switch to “Base64 → Image”, paste the text or the whole data URI, and the tool shows the picture and lets you download it. It works out the image type from the data itself.

Is my image uploaded?

No. Encoding and decoding happen in your browser with built-in functions. Nothing is sent to our servers.

Do Base64 images work in email?

Not reliably. Support differs between email programs. Older desktop Outlook for Windows, for example, doesn’t show them, and they make every message bigger. An image link or an attachment is safer.