How to convert an image to Base64
- Drop an image on the box or tap “Choose image”.
- Copy the format you need: the full data URI, the Base64 text alone, or a snippet for your page.
- 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.
