Image to Base64
Turn a small image into a text string you can paste directly into HTML, CSS or JSON — no separate file and no extra network request.
How to use the Image to Base64
- Drop in a small image — icons, logos and simple graphics work best.
- Choose the output you need: a raw data URI, an HTML tag, a CSS rule or Markdown.
- Press Copy and paste it straight into your code.
What a data URI is
A data URI carries a file's contents inside the URL itself instead of pointing at a location. The structure is data:, the MIME type, ;base64,, then the encoded bytes:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUg…
Anywhere a URL is accepted — src, CSS url(), a Markdown image — a data URI works instead. The image travels with the document, so there is no second request and nothing to break if a file moves.
When to use one, and when not to
Good uses: tiny icons in a CSS sprite, a logo in an HTML email, an inline SVG placeholder, images in a self-contained HTML file that must work offline, or embedding an image in a JSON payload.
Poor uses: photographs and anything above roughly 10 KB. Three costs stack up. Base64 adds about 33% to the size. The data cannot be cached separately, so it is re-downloaded with every page load. And because it sits in the HTML or CSS, it blocks rendering in a way a separate image request does not.
A useful rule: if the image is small enough that a separate HTTP request costs more than the bytes, inline it. Otherwise link to it.
SVG deserves a mention
SVG is text, so it does not need Base64 at all. You can put the markup directly into a data URI with only the special characters escaped, avoiding the 33% overhead entirely — or better, paste the SVG straight into your HTML, where CSS can then style it.
Frequently asked questions
Why is the encoded string bigger than the file?
Base64 represents three bytes with four characters, adding about 33%. The data URI prefix adds a little more. That overhead is the price of embedding binary data in text.
Do data URIs work in email?
In some clients. Gmail's web interface and several others block them. For HTML email, hosted images with absolute URLs remain the reliable choice.
Is there a size limit?
Browsers accept very large data URIs, but practical limits arrive sooner: bloated HTML, slow parsing and no caching. This tool caps input at 2 MB and warns above 100 KB.
Can I convert a data URI back to an image?
Yes. Paste the part after the comma into the Base64 Decoder and download the result, or simply paste the whole URI into a browser address bar.
Related tools
Encode text or files to Base64, with URL-safe output available.
Decode Base64 back to text, with automatic URL-safe detection.
Shrink image file size with a quality slider or a target size.
Convert images to and from WebP, with quality control.
Convert colours between HEX, RGB, HSL and HSV with a live preview.