🧩

Image to Base64

Encode a remote image as a base64 string.

POST 10 credits /v1/convert/image-to-base64
curl -X POST "https://convert.toolkitapi.io/v1/convert/image-to-base64" \
  -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-base64",
    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-base64", {
  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
{
  "base64": "UklGRiIAAABXRUJQVlA4TBUAAAAv..."
}

Description

Encode a remote image as a base64 string.

How to Use

1

1. POST a JSON body with the image `url`.

2

2. Optionally set `format` and `quality` to re-encode before returning base64.

3

3. Read the `base64` string from the response.

About This Tool

Fetches a remote image and returns it as a base64-encoded string. Optionally re-encodes to a different target format and quality before encoding.

Useful for embedding images inline in JSON payloads, emails, and database records — any context that prefers a single string over a file reference.

Why Use This Tool

Frequently Asked Questions

Does the result include a `data:` prefix?
No — only the raw base64. Prefix `data:image/...;base64,` yourself when constructing a data URI.
How big can the source be?
The source image size is capped at the server-configured download limit (typically a few MB).
Is the response chunked?
No — the full base64 string is returned in a single JSON response.

Start using Image to Base64 now

Get your free API key and make your first request in under a minute.