How to Convert an Image to Base64
To convert an image to Base64, drop it in the box above, then copy the data URI or the plain Base64 text. The image is read by your browser, so even private screenshots never leave your device.
- Add the image. Drag it in, click to choose a file, or copy an image and press Ctrl+V (Cmd+V on a Mac).
- Pick the code. The data URI, the Base64 text, an HTML tag and a CSS rule appear together, with the file size before and after.
- Copy or save. Click Copy next to the one you need, or download everything as a text file.
Which Base64 Code to Use
| Code | Looks like | Use it for |
|---|---|---|
| Data URI | data:image/png;base64,iVBOR... | Any field or attribute that takes an image address; forms that ask for a "Base64 URL" |
| Base64 only | iVBOR... | APIs and JSON fields that want the encoded file on its own |
| HTML | <img src="data:..." alt=""> | Small icons inside one HTML file or a code snippet |
| CSS | background-image: url("data:...") | Small icons and patterns inside a stylesheet |
SVG files are encoded as they are, so they stay sharp at any size. Other formats are not re-compressed: the Base64 holds exactly the file you added.
Convert Base64 Back to an Image
Choose Base64 to image at the top of the tool and paste the text. A full data URI works, and so does the Base64 on its own - the format (PNG, JPG, GIF, WebP, SVG and others) is recognised from the content. Check the preview, then download the file or turn it into a link.
Base64 or a Link?
Base64 is handy when the image has to travel inside the code: a tiny icon in a stylesheet, a test fixture, an API that only takes Base64. For anything else a link is usually better:
- Size. Base64 is about 33% bigger than the file, and it is downloaded again with every page or email that contains it.
- Email. Gmail, Outlook and other apps often block or strip Base64 images.
- Forums and chat. They expect an image URL and have length limits.
Press Get a link instead to upload the same image and get a short, permanent image URL with HTML, BBCode and Markdown codes - free, no account needed.