Converting files through the API
Convert between PNG, JPG, SVG, PDF and Lottie, and render Lottie animations as GIF or video.
Upload a file to POST /v3/convert/{operation} to convert it. Conversions need your Client ID and Client Secret, use API credits, and must be turned on for your app.
What you can convert
|
Operation |
From |
To |
Result |
|---|---|---|---|
|
|
PNG |
JPG |
Instant |
|
|
JPG |
PNG |
Instant |
|
|
SVG |
PNG |
Instant |
|
|
SVG |
JPG |
Instant |
|
|
SVG |
|
Instant |
|
|
SVG |
Lottie JSON |
Instant |
|
|
Lottie JSON |
Smaller Lottie JSON |
Instant |
|
|
Lottie JSON |
dotLottie |
Instant |
|
|
Lottie JSON |
GIF |
Job to poll |
|
|
Lottie JSON |
WebP |
Job to poll |
|
|
Lottie JSON |
MP4 |
Job to poll |
|
|
Lottie JSON |
WebM |
Job to poll |
Lottie to SVG is only available in the iconscout.com editor, not through the API.
Instant conversions
The converted file comes back directly in the response. Save the response straight to a file.
curl -X POST "https://api.iconscout.com/v3/convert/svg-to-png" \ -H "Client-ID: $ICONSCOUT_CLIENT_ID" \ -H "Client-Secret: $ICONSCOUT_CLIENT_SECRET" \ -F "file=@logo.svg" \ -o logo.png
Lottie to GIF, WebP, MP4 or WebM
These renders can take tens of seconds, so they run as a job.
- Send the Lottie JSON file. Optionally add
widthandheight(up to 4096 px) andtransparent. - You get a 202 response with a job ID and a
Retry-Afterinterval. - Poll
GET /v3/convert/jobs/{job}everyRetry-Afterseconds. The status goes queued → processing → completed or failed. A 1080×1080 MP4 usually takes well under a minute. - When it's completed, download the file from
download_urlorGET /v3/convert/jobs/{job}/download. Downloading again doesn't use more credits. - Save it before
expires_at. After that, the file is deleted and you need to render it again.
Need a transparent video? Use lottie-to-webm. MP4 has no transparency.
SVG to Lottie options
|
Field |
Details |
|---|---|
|
|
Required. fade-in, fade-in-up, fade-in-down, scale-up, scale-down, slide-in-left, slide-in-right, draw or pop |
|
|
Animation length in seconds, up to 60 |
|
|
Pause before and after the animation, in seconds, up to 60 |
|
|
Animate the SVG's parts one after another instead of all together |
File rules
- The file must match the operation's input format, by extension, file type and content.
- SVGs with a
<!DOCTYPE>or<!ENTITY>declaration are refused. - The upload size limit depends on your plan.
GET /v3/convert/operationsshows it, along with each operation's credit cost andavailable_on_your_plan.
Credits
- Each conversion uses credits from your API credit balance. Check current costs with
GET /v3/convert/operations. - Failed conversions aren't charged.
You can send an Idempotency-Key header so a retried request doesn't run twice. For instant conversions, if the conversion worked but you lost the response, it can't be fetched again. A new request is charged again. If that matters, use a job-based conversion, since you can always poll the original job.
Common errors
|
Error |
Reason |
What to do |
|---|---|---|
|
400 |
|
The file doesn't match the operation, or it's an SVG with DOCTYPE or ENTITY |
|
403 |
|
Your plan doesn't include this conversion, or File Converter is off for your app |
|
404 |
|
Check the operation name or job ID |
|
409 |
|
The job isn't done yet. Keep polling. |
|
410 |
|
The file was deleted after |
|
413 |
File too large |
Check |
|
429 |
|
Too many requests, or no credits left (Article 9) |
|
500–504 |
Conversion failed or timed out |
You aren't charged. Retry once. |
For more details, see IconScout API docs.