Go Pro
AVIF ToolsConvert AVIF to JPGConvert AVIF to PNGConvert AVIF to WebPConvert JPG to AVIFConvert PNG to AVIFConvert WebP to AVIFImage ConvertersConvert PNG to JPGConvert JPG to PNGConvert WebP to JPGConvert WebP to PNGConvert GIF to JPGConvert GIF to PNGConvert SVG to JPGConvert SVG to PNGCompressorsCompress AVIF ImagesCompress JPG ImagesCompress PNG ImagesPricing

Conversion API

The iLoveAVIF API gives you server-side image conversion via a simple REST endpoint. Send a file, get a converted file back. Requires a Pro subscription ($4.99/mo) and an API key from your dashboard.

Quick Start

curl -X POST https://iloveavif.com/api/v1/convert \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "file=@photo.jpg" \
  -F "format=avif" \
  -F "quality=75" \
  --output photo.avif

Authentication

All API requests require an API key sent via the X-API-Key header. Keys use the format ilav_ followed by 40 hex characters (45 characters total).

Create and manage API keys in your dashboard. You can have up to 5 active keys. Keys are shown once at creation — only the SHA-256 hash is stored on our servers.

Endpoint: POST /api/v1/convert

POST https://iloveavif.com/api/v1/convert

Send a multipart/form-data request with the image file and conversion parameters. The response is the converted image as raw binary data.

Request Fields

FieldTypeRequiredDescription
filebinaryYesImage file (max 10MB, max 10 megapixels)
formatstringYesOutput format: avif, jpg, png, or webp
qualityintegerNo1–100 (default 75). Ignored for PNG (lossless).

Response Headers

HeaderDescription
Content-TypeMIME type of the output (image/avif, image/jpeg, etc.)
Content-Dispositionattachment; filename="photo.avif"
X-Original-SizeInput file size in bytes
X-Output-SizeOutput file size in bytes
X-SavingsCompression savings percentage (e.g. 60%)
Cache-Controlno-store

Supported Formats

InputAVIFJPGPNGWebP
AVIF
JPG
PNG
WebP

Response

Success (200)

The response body is the raw converted image binary. Use the Content-Type header to determine the output format and X-Savings to check compression efficiency.

Error (JSON)

All errors return JSON with an error field:

{
  "error": "Daily rate limit exceeded",
  "limit": 1000,
  "used": 1000,
  "resets": "2026-02-26T00:00:00Z"
}

Error Codes

StatusConditionExample Response
400Missing file, invalid format, bad quality, or exceeds 10MP{"error":"No file provided"}
401Missing or invalid API key{"error":"Invalid API key"}
403User not on Pro plan{"error":"Pro subscription required"}
413File exceeds 10MB{"error":"File exceeds 10MB limit"}
429Daily rate limit exceeded{"error":"Daily rate limit exceeded","limit":1000}
500Conversion failure or internal error{"error":"Conversion failed"}

Rate Limits

Pro subscribers can make up to 1,000 API requests per day (UTC). The limit is enforced atomically — concurrent requests cannot exceed the limit. When the limit is reached, the API returns a 429 response with limit, used, and resets fields.

CORS

The conversion endpoint includes CORS headers for browser-based integrations:

Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, OPTIONS
Access-Control-Allow-Headers: X-API-Key, Content-Type
Access-Control-Max-Age: 86400

An OPTIONS preflight handler returns these headers with a 204 response. This means you can call the API directly from browser JavaScript.

Code Examples

curl

curl -X POST https://iloveavif.com/api/v1/convert \
  -H "X-API-Key: ilav_YOUR_KEY_HERE" \
  -F "file=@input.jpg" \
  -F "format=avif" \
  -F "quality=60" \
  --output output.avif

JavaScript (fetch)

const form = new FormData();
form.append("file", fileInput.files[0]);
form.append("format", "webp");
form.append("quality", "80");

const res = await fetch("https://iloveavif.com/api/v1/convert", {
  method: "POST",
  headers: { "X-API-Key": "ilav_YOUR_KEY_HERE" },
  body: form,
});

const blob = await res.blob();
const url = URL.createObjectURL(blob);

Python (requests)

import requests

res = requests.post(
    "https://iloveavif.com/api/v1/convert",
    headers={"X-API-Key": "ilav_YOUR_KEY_HERE"},
    files={"file": open("input.png", "rb")},
    data={"format": "avif", "quality": "75"},
)

with open("output.avif", "wb") as f:
    f.write(res.content)

print(f"Savings: {res.headers['X-Savings']}")

Limitations

Get API access with a Pro subscription — $4.99/mo for 1,000 conversions/day.

Get Started