Drop an image and get its Base64 data URI, plus the CSS and HTML you would paste it into. Because it runs locally, this is safe for an image you would not upload — a screenshot with customer data in it, an ID photo, an internal diagram.
When inlining an image is worth it
Inline when: the image is under about 4 KB, it is needed to render the first screen, and it is unlikely to change. Small icons and a logo qualify.
Do not inline when: the image is large, reused across pages, or changes independently of the CSS. A data URI cannot be cached separately, so a 200 KB inlined image is re-downloaded with every stylesheet change, and it grows by a third in the encoding.
The size penalty is exactly 33%
SVG usually should not be Base64 at all
url() — the result is smaller than the Base64 and still valid CSS. Better still, inline the <svg> element in your HTML, where it can be styled.Other names for this
Also searched as “png to base64”, “jpg to base64”, “image to data uri”.
Questions
- Why is the Base64 bigger than my image?
- Base64 encodes three bytes as four characters, so the string is always about 33% larger. That is inherent to the encoding.
- Can I convert several images at once?
- Yes. Drop as many as you like; each gets its own data URI and snippets.
- Should I do this for a photograph?
- Almost never. Photographs are large, and a data URI cannot be cached separately from the file that contains it.
- Does my text leave the browser?
- No. Everything runs as JavaScript in this tab — there is no server involved and no request is made. Open the Network panel and watch, or turn your Wi-Fi off and keep using the tool.