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.

  1. Add the image. Drag it in, click to choose a file, or copy an image and press Ctrl+V (Cmd+V on a Mac).
  2. 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.
  3. Copy or save. Click Copy next to the one you need, or download everything as a text file.

Which Base64 Code to Use

CodeLooks likeUse it for
Data URIdata:image/png;base64,iVBOR...Any field or attribute that takes an image address; forms that ask for a "Base64 URL"
Base64 onlyiVBOR...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
CSSbackground-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.

Frequently Asked Questions

How do I convert an image to Base64?
Drop the image in the box on this page, choose it from your device or paste it with Ctrl+V. The data URI, the plain Base64 text, an HTML img tag and a CSS background appear at once - click Copy next to the one you need.
What is a data URI?
A data URI puts the file itself inside the address: data:image/png;base64, followed by the Base64 text. Browsers show it like a normal image link, so it works in an img tag, in CSS or in a JSON field that asks for a Base64 image.
What is the difference between the data URI and plain Base64?
The data URI starts with data:image/...;base64, and works wherever an image address is expected. Plain Base64 is only the encoded text, for APIs and JSON fields that ask for the Base64 string on its own.
Why is the Base64 text bigger than my image?
Base64 writes every 3 bytes as 4 characters, so the text is about a third larger than the file. A 300 KB photo becomes about 400 KB of text.
How do I turn Base64 back into an image?
Switch to "Base64 to image", paste the text - with or without the data:image prefix - and the picture appears. Download it as a file, or get a link to it.
Is my image uploaded?
No. The conversion runs in your browser and the image stays on your device. Only if you press "Get a link" is the file uploaded, to give you a normal image URL.
When should I use a link instead of Base64?
For anything over a few kilobytes, in emails, on forums and in chat. Many email apps block Base64 images, and large data URIs slow pages down because they cannot be cached. A hosted link is short and loads once.