How to convert an image to WebP, PNG, JPEG or AVIF with an API
Updated 2026-11-10
Use when an image must be changed between formats such as PNG, JPEG, WebP, GIF, TIFF, BMP, ICO or AVIF.
From an MCP client, add https://tanod.dev/mcp and call image_convert; its free daily calls are applied automatically, no key or signup.
POST an image URL and a target format to /v1/image/convert. It returns the converted image as base64.
Request
to is png, jpeg, webp, gif, tiff, bmp, ico (16 to 256 px icon sizes) or avif. Options: quality, progressive (jpeg), optimize (png), lossless (webp) and background. Input is a public image URL (up to 10 MB) or image_base64 (up to 10 MB decoded; a data:image/...;base64, prefix is fine).
curl -s -X POST https://tanod.dev/v1/image/convert \
-H 'X-Tanod-Free: 1' -H 'content-type: application/json' \
-d '{"url": "https://tanod.dev/icon.png", "to": "webp"}'The file comes back as base64 in the JSON. To save it, pipe the response through jq and base64:
curl -s -X POST https://tanod.dev/v1/image/convert \
-H 'X-Tanod-Free: 1' -H 'content-type: application/json' \
-d '{"url": "https://tanod.dev/icon.png", "to": "webp"}' \
| jq -r '.data_base64' | base64 -d > converted.webpResponse
{
"operation": "convert",
"input": {
"format": "png",
"width": 256,
"height": 256,
"bytes": 2183,
"frames": 1,
"animated": false,
"has_alpha": true
},
"source_url": "https://tanod.dev/icon.png",
"final_url": "https://tanod.dev/icon.png",
"format": "webp",
"content_type": "image/webp",
"bytes": 1864,
"width": 256,
"height": 256,
"data_base64": "UklGRkAHAABXRUJQ",
"notes": [],
"source": {
"library": "Pillow",
"license": "MIT-CMU (HPND)",
"url": "https://python-pillow.org"
}
}Which target format to pick
jpeg: photos. No transparency; lossy,quality85 by default;progressivefor large web images.png: screenshots, logos and anything with transparency. Lossless;optimizemakes it smaller but slower.webp: smaller web images that keep transparency. Lossy atquality80 by default, orlosslesstrue.ico: favicons. Icon sizes 16, 32, 48, 64, 128 and 256 px, up to the image's longest side; a larger image is scaled into them (a note says so).bmpandtiff: for tools that need them. BMP has no transparency; TIFF uses LZW compression.
When transparency is flattened, the response's notes say which colour was used.
Limits and caveats
Paying by card instead? The Apify actor Image Toolkit (tanod/image-toolkit) does the same at USD 0.005 per image plus Apify's start fee per run.
Transparency. JPEG and BMP have no alpha, so transparent areas are flattened onto background (default white).
SVG is not accepted. Vector input is refused with a 422. Rasterise it first.
Inputs and sizes. PNG, JPEG, WebP, GIF, TIFF, BMP, ICO or AVIF (first frame only); HEIC, SVG, PDF, PSD and EPS get a 422. Over 40 megapixels in (image_too_large) or 15 MB or 50 megapixels out (output_too_large) is a 413. Refusals are not charged. EXIF, GPS, XMP and IPTC metadata are not copied, images are not logged, and a result is kept (24 hours) only with output url.
Doing this by hand? Use the free image format converter in your browser.
Download link. Add "output": "url" to the request and the file is stored for 24 hours and returned as a link (url, expires_at, sha256) instead of base64, which keeps it out of your context window. The price is the same. How the links work.
Price and free allowance
USD 0.002 per call, paid in USDC on Base, Polygon, Solana, BNB Chain or Arbitrum with x402. 3 free calls per IP per UTC day with the header X-Tanod-Free: 1. The pool is shared by every image operation. MCP tool: image_convert at https://tanod.dev/mcp, where the free tier is automatic.
Use it from Claude without writing code: in claude.ai or Claude Desktop, add https://tanod.dev/mcp/images?via=image-convert-api as a custom connector (steps), then ask in plain words, for example "Convert this PNG to WebP." The free daily allowance is applied automatically over MCP. Beyond it a call needs an x402 payment, which these clients can make.
Related guides: How to compress an image to a target file size with an API, How to resize an image from a URL with an API, How to generate a favicon set (ICO, PNG, Apple touch icon) from an image. Back to tanod.dev or the guide index. Results are automated and heuristic.