Image to Data URI
Encode a remote image as a `data:` URI string.
POST
10 credits
/v1/convert/image-to-data-uri
curl -X POST "https://convert.toolkitapi.io/v1/convert/image-to-data-uri" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"url": "https://toolkitapi.io/logo.png", "format": "webp", "quality": 85}'
import httpx
resp = httpx.post(
"https://convert.toolkitapi.io/v1/convert/image-to-data-uri",
json={"url": "https://toolkitapi.io/logo.png", "format": "webp", "quality": 85},
)
print(resp.json())
const resp = await fetch("https://convert.toolkitapi.io/v1/convert/image-to-data-uri", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({"url": "https://toolkitapi.io/logo.png", "format": "webp", "quality": 85}),
});
const data = await resp.json();
console.log(data);
# See curl example
Response
200 OK
{
"data_uri": "data:image/webp;base64,UklGRiIAAABXRUJQVlA4TBUAAAAv..."
}
Description
Encode a remote image as a `data:` URI string.
How to Use
1
1. POST a JSON body with the image `url`.
2
2. Optionally set `format` and `quality`.
3
3. Use the returned `data_uri` wherever a URL is accepted.
About This Tool
Fetches a remote image and returns a ready-to-use `data:` URI. Optionally re-encodes to a different target format and quality before encoding.
Drop the result directly into ``, CSS `background-image`, or inline SVG `
Why Use This Tool
- Zero-extra-request images — Inline tiny images to cut HTTP requests
- Email signatures — Embed logos as data URIs for reliable rendering
- Static site builds — Bake small images directly into HTML/CSS
- Offline caches — Snapshot remote images for offline use
Frequently Asked Questions
When should I use data URIs?
For very small images (icons, sparklines). Large images inflate HTML and defeat browser caching.
What MIME type is used?
The MIME type reflects the `format` chosen, or the detected format if `format` is omitted.
Is there a size limit?
Sources are capped at the server-configured download limit (typically a few MB).
Start using Image to Data URI now
Get your free API key and make your first request in under a minute.