Converts an image to a Base64 string, data URI, HTML tag, or CSS rule.
Input
pixel.png (1×1 PNG, 70 bytes), Data URI
Output
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==
Input
Same image, Raw Base64
Output
iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==
Input
Same image, HTML <img>
Output
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==" alt="" />
An image to Base64 converter turns a picture file into a long string of text that you can paste straight into code. Drop in a PNG or a JPG and the encoded string appears at once. This free image to Base64 tool runs in your browser and the file never leaves your device. You can copy a full data URI or the raw Base64 code with one click.
Developers use Base64 images to cut down on extra file requests. A tiny icon can sit inside a stylesheet or an HTML page as text. Email designers embed small logos so they show without a separate download. API work often needs an image sent as a JSON field and Base64 makes that possible. And it is handy for quick demos where you cannot host a file.
Here is what the result looks like. A data URI starts with data: followed by the file type and the word base64 and a comma. Everything after the comma is the image written in 64 safe characters. A browser reads that string and draws the picture without fetching anything. The raw option gives you only the part after the comma, which is what many APIs and databases expect. The HTML option wraps the data URI in an img tag and the CSS option wraps it in a background-image rule.
Know the trade-offs before you use it everywhere. Base64 makes the data about a third larger than the original file, as the size panel shows. A big photo turned into text will bloat your page and can't be cached on its own the way a normal image can. For that reason it's best for small assets such as icons and tiny logos or placeholders. Anything above a few kilobytes is better kept as a regular file. The tool accepts images up to 10 MB so you can still convert a larger one when you need to.
Privacy matters here because pictures can be personal. Your image is read by your browser and turned into text on your device. Nothing is uploaded or stored. To go the other way and decode text use the Base64 encode and decode tool. For URLs with special characters try the URL encode and decode tool. If you also work with data files the JSON formatter keeps your payloads tidy.
More Developer Tools