Convert an image to a Base64 data URI
Turn a small image into text you can paste straight into CSS, HTML, an email template or a JSON payload, with no separate file to host.
- Runs in your browser
- Nothing uploaded
- No account
- No watermark
- Free
How to image to Base64
- Drop in your image.
- Choose whether you want the bare data URI, a CSS rule or an img tag.
- Re-encode as WebP first if the original is large, which usually cuts the text considerably.
- Copy the result.
When this is a good idea
Base64 encoding turns binary into text, which lets an image live inside a stylesheet, an HTML file or a JSON field instead of as a separate file. The benefit is one fewer network request, and the ability to ship an image somewhere that can only carry text.
It is a good trade for a genuinely small image: an icon, a tiny logo, a one pixel gradient, an SVG. Those are cases where the request costs more than the bytes.
When it is a bad idea
Base64 makes a file about thirty three percent larger. That cost sits inside your HTML or CSS, which means it is downloaded before the page can render, it cannot be cached separately, and it cannot be lazy loaded. Inline a photograph and you have made your stylesheet enormous and your page slower, which is the opposite of what you were trying to do.
The rough rule: under about 2 KB, inlining usually wins. Over about 10 KB it usually loses. In between, measure.
Shrink it before you encode it
If you are going to inline an image, make it as small as possible first. The re-encode option here converts to WebP before encoding, which often halves the result. For anything with a flat colour or a simple shape, consider whether an SVG would do the job in a fraction of the characters, since SVG is already text.
Email is the exception
Inline images are tempting for email templates, but several major clients, Outlook among them, refuse to render Base64 images at all. For email, host the image and link to it.
Questions
What is a data URI?
A way of putting a file's contents directly into a URL, so that src or url() carries the image itself instead of pointing at a file somewhere.
Does Base64 make the image smaller?
No, it makes it about a third larger. What it saves is a network request, which is only worth it for very small files.
Can I use a Base64 image in an email?
Not reliably. Several major email clients refuse to render them. Host the image and link to it instead.
Is there a size limit?
Nothing technical here, but keep it small. Inlining anything over about 10 KB usually makes your page slower rather than faster.
The rest of the toolkit
Every one of these runs on your own device. Nothing is uploaded, and there is no counter anywhere.
Image tools
Text and generators