Image to Base64 converter
Choose a picture to get its Base64 text as a data URI, plain Base64, a CSS url() or an img tag. Or paste Base64 below to preview the picture and save it. Nothing leaves your device.
Runs in your browser: nothing you enter is sent anywhere.
How to use it
- To encode, choose or drop a picture. The tool shows the original size, the length of the Base64 text and how much larger it is.
- Pick the format you need: a data URI for
src or href, raw Base64 for APIs and JSON, a CSS url() for backgrounds, or a ready <img> tag.
- Press Copy.
- To decode, paste Base64 or a data URI into the lower box. The picture appears with its detected type and size, and you can download it.
How it works
Base64 turns each group of 3 bytes into 4 characters from a 64-letter alphabet, padding the end with = when the last group is short. The length is therefore 4 × ⌈bytes ÷ 3⌉. For example, a 1,000-byte file gives 4 × 334 = 1,336 characters, which is 34% more. The picture type in a data URI comes from the file; when decoding, the type is recognised from the file signature (for example PNG files start with the bytes 89 50 4E 47).
Tips
- Keep encoded images small: compress or resize the picture first.
- Files over 10 MB are refused here because the text would be too long to handle comfortably in a text box.
- Data URIs are not cached separately from the page that contains them.
Frequently asked questions
Why is the Base64 text bigger than the image?
Base64 writes every 3 bytes as 4 text characters, so the text is about one third (33%) longer than the file. A 1,000-byte image becomes 1,336 characters once padding is counted.
When should I embed an image as a data URI?
For very small pictures such as icons, where saving a request matters more than size. Large photos are better as normal files: Base64 makes the page heavier and the browser cannot cache the picture separately.
Can I paste Base64 without the data: prefix?
Yes. Plain Base64, a full data URI, a CSS url() or an img tag all work. The picture type is detected from the first bytes, so the prefix is not needed. URL-safe Base64 and missing padding are accepted too.
Is my image uploaded anywhere?
No. The file is read and encoded by your browser, and decoded pictures are created locally as well. Nothing is sent to a server.