Image to Base64 Converter
Convert an image to a Base64 data URI for embedding directly in HTML, CSS or JSON.
What the output looks like
You get a complete data URI: data:, the file's type, ;base64, and then the encoded bytes. Here is a real 1 × 1 red PNG (69 bytes) as the tool outputs it:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCCThat string is 114 characters long. A JPG starts with data:image/jpeg;base64, and a WebP with data:image/webp;base64,.
The tool reads your file's bytes and encodes them directly. Nothing is redrawn or re-compressed, so the image decodes back to exactly the same file, metadata and all.
How much bigger the text is than the file
Base64 turns every 3 bytes into 4 characters, so the data is about a third larger than the original, plus the short prefix:
| File size | Data URI length |
|---|---|
| 2 KB (2,048 bytes) | 2,754 characters |
| 10 KB (10,240 bytes) | 13,678 characters |
| 100 KB (102,400 bytes) | 136,558 characters |
The label above the output counts these characters and shows them as KB, which is why it reads higher than your file size.
Pasting it into HTML, CSS or JSON
- CSS:
background-image: url(data:image/png;base64,...)with the full string in place of the dots. - HTML: paste the whole string as the image element's
srcattribute. - JSON and APIs: many APIs want the raw Base64 only. Delete everything up to and including the first comma before you send it.
Embedded images can't be cached on their own: the bytes are downloaded again with every copy of the page or stylesheet that contains them. That's a fair trade for a small icon used once, and a poor one for a large photo.
Check what's inside before you embed it
Because the original bytes are kept, so is everything stored in the file. A phone photo encoded here still carries its EXIF data, which can include GPS position, inside the Base64. Anyone who decodes the string can read it. If that matters, run the photo through JPG to PNG or the Image Compressor first, since both write a fresh file from pixels only, and encode the result. The encoding happens in your browser; the image isn't uploaded.
How to use this tool
- 1Choose an image (JPG, PNG or WebP).
- 2Adjust the options if needed.
- 3Click Process & download.
Frequently asked questions
Is Base64 a form of encryption?+
No. It's a reversible text encoding with no key, so anyone with the string can turn it back into the image in seconds. Don't use it to hide anything.
Does encoding to Base64 reduce image quality?+
No. The bytes are encoded exactly as they are, so decoding gives back the identical file.
Which image types can I encode?+
The file picker accepts PNG, JPG and WebP. The data URI's prefix uses the type your browser reports for the file.
Will the same image always give the same string?+
Yes. Base64 is deterministic, so identical files always produce identical output. If two strings differ, the files differ.
Embed this tool on your website
Free to use on blogs, school sites and intranets. Paste this code into your page's HTML; please keep the credit line.
<iframe src="https://utilityapp.lat/embed/image/image-to-base64" title="Image to Base64 Converter" width="100%" height="600" style="border:0;max-width:760px" loading="lazy"></iframe> <p style="font-size:13px"><a href="https://utilityapp.lat/image/image-to-base64">Image to Base64 Converter</a> by UtilityApp</p>