Small images sometimes belong inside your code rather than next to it. This image to base64 converter turns an image file into a Base64 string and hands it back four ways: a full data URI, the bare Base64 payload, a ready made CSS background-image rule, and an HTML img tag. Paste the CSS version into a stylesheet and the icon ships with it, no extra HTTP request, no broken relative path. The size cost is shown up front too: Base64 output runs about 1.37 times the original bytes, which is why the uploader caps files at 5 MB and why tiny icons are the sweet spot. As a base64 image encoder it runs fully client side, so nothing is transmitted.
Always freeNo sign upRuns in your browser
Drop files here, or click to browse
Up to 5 MB. Smaller files are better suited for Base64.
Drop a file on the uploader. A thumbnail preview appears with the original file size next to an estimate of the encoded size, roughly 1.37 times larger.
02
Pick an output tab
Switch between the Data URI, Raw Base64, CSS, and HTML tabs. The CSS tab wraps the URI in a background-image rule, and the HTML tab produces a complete img element you can paste into markup.
03
Copy the string
Hit the copy button above the text box and paste the result into your stylesheet, HTML, or JSON payload. Use another swaps in a different file without reloading the page.
Why Image to Base64
Encode any image as a Base64 data URI for inline embedding.
Get data URI, raw Base64, CSS background, or HTML img tag.
Useful for small icons or email-safe embeds, never exceeds your image size.
Common questions
Why is my Base64 string a third bigger than the image file?
Base64 represents every 3 bytes of binary as 4 text characters, an unavoidable 33 percent overhead, and the data URI prefix plus padding nudges it a little higher. That's why the preview estimates about 1.37 times the original size.
What's the difference between the Data URI and Raw Base64 tabs?
The Data URI tab includes the data:image/...;base64, prefix that browsers require to render the string directly. Raw Base64 is just the encoded payload, which is what you want when an API field or JSON schema expects the bare string.
How small should an image be before inlining it as Base64?
A few kilobytes is the comfortable zone; think icons, logos, and tiny UI textures. It only pays to convert image to base64 string output for assets that small, because larger files bloat your CSS or HTML and lose the benefit of separate caching.
Does Base64 image output work in email templates?
Support is patchy. Some clients render data URI images fine, while several major webmail clients strip or block them. Test in your actual target clients before committing, and keep a hosted image fallback for the ones that refuse.
Can I encode a WEBP or SVG file to Base64 here?
Yes, any image type your browser recognizes is accepted, and the data URI carries the file's real MIME type, such as image/webp or image/svg+xml. For SVG specifically, plain URL encoding is sometimes more compact than Base64, but both work.
Will a Base64 data URI show up in Markdown on GitHub?
No, GitHub's image proxy doesn't serve data URIs, so the image simply won't render there. Inlined images are best kept to HTML, CSS, and JSON payloads you control end to end.
Are Base64 inlined images cached by the browser?
Not independently. The image data is cached only as part of the stylesheet or page that contains it, so changing the image invalidates that whole file. That's another reason to reserve inlining for small, rarely changing assets.
How do I convert image to base64 online with this tool?
Drop an image under 5 MB onto the uploader, then pick an output tab. To do image to base64 online you don't press a convert button, the encoding runs the moment the file loads, and you just copy the Data URI, raw payload, CSS, or HTML you need.
Is this an online convert image to base64 tool or does it install anything?
It's fully online with nothing to install. As an online converter image to base64, it runs the encoding in your browser tab, so the file never uploads and the string appears instantly. That also means it keeps working if your connection drops after the page loads.
Do I need to convert into base64 in a specific order of steps?
No, it's a single action. To convert to base64 online, just load the image; the tool reads it and fills all four output tabs at once. Switch between Data URI, Raw Base64, CSS, and HTML without re-uploading, and hit Use another to swap files.
What does it mean to base64 encode image data for a JSON payload?
It turns the binary image into plain text that fits inside a JSON string field, which is why APIs often ask for it. Use the Raw Base64 tab for that image to base64 conversion, since JSON wants the bare payload without the data URI prefix.
Is this base64 converter limited to images?
The uploader accepts image files, so you convert in base64 the picture types your browser can decode. It isn't a general binary encoder for zips or PDFs; for those you'd need a different tool. Here the focus is images headed into CSS, HTML, or an API field.
Can I convert file to base64 online if it's an image?
Yes, that's exactly the case it handles. To convert file to base64, drop the image in and copy the result; the tool encodes image files up to 5 MB. Non-image files aren't supported here, since the output is built for inline image embedding.
How do I convert image to data uri for a CSS background?
Open the CSS tab after loading your image. It wraps the data URI in a ready-made background-image rule you can paste straight into a stylesheet, so the icon ships with the CSS and needs no separate request. The Data URI tab gives you the bare data: string if you'd rather build the rule yourself.
Can this tool base64 decode image strings back into a picture?
No, this one only encodes. To base64 decode image data, use the Base64 to Image tool on this site: paste the string or data URI there and it renders the picture and offers a download. Think of the two tools as opposite directions of the same job.
I have the output here, how do I turn a base64 string to image again?
Copy the Raw Base64 or Data URI from this page, then open the Base64 to Image tool and paste it in. It renders the payload as a picture and lets you save it as a real file, which is a quick way to confirm your encoded output is intact.