# SVG to PNG Converter API: SVG Code or URL to PNG Image (`eliai/svg-to-png`) Actor

Convert SVG to PNG. Paste SVG code or give SVG file URLs, get a PNG download link plus a ready data:image/png;base64 URI. Set width and background. Batch input, one JSON row per image. For AI agents that draw charts or icons as SVG, and developers. Failed items are never charged.

- **URL**: https://apify.com/eliai/svg-to-png.md
- **Developed by:** [Broke to Built](https://apify.com/eliai) (community)
- **Categories:** Developer tools, AI
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 image converteds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

### SVG to PNG Converter API: SVG Code or URL to PNG Image

**Paste SVG code or give SVG file URLs. Get a PNG download link and a ready `data:image/png;base64` URI back. One JSON row per image.**

| You give it | You get back | You pay (Free plan) |
|---|---|---|
| SVG markup, SVG URLs, or a list of either; optional width and background | A PNG file in the run's storage, its link, width/height, byte size, and a data URI | **$0.002 per image converted** |

Failed items are written to the dataset with the reason and are never charged.

#### Try it in one click

The input form is pre-filled with a small sample SVG. Press **Start**.

```json
{}
```

Real output from that input (run on 2026-11-11, link shortened):

```json
[
  {
    "ok": true,
    "source": "text#1",
    "width": 240,
    "height": 120,
    "pngBytes": 3986,
    "pngKey": "image-0001.png",
    "pngUrl": "https://api.apify.com/v2/key-value-stores/.../records/image-0001.png?signature=...",
    "dataUri": "data:image/png;base64,iVBORw0KGgo..."
  }
]
```

### Who this is for

- **AI agents and LLM apps** that draw charts, diagrams or icons as SVG but need a PNG to show in chat, email, Slack or a PDF.
- **Developers** who need SVG rasterized server-side without installing a headless browser.
- **No-code builders** (Make, Zapier, n8n) who get SVG from one tool and must hand PNG to the next.

### Input

| Field | What it does |
|---|---|
| `svg` | One SVG as markup or as a URL. |
| `svgUrls` | Many SVG URLs at once. |
| `svgItems` | Many SVG markup strings at once. |
| `width` | Output width in pixels; height keeps the aspect ratio. Empty = the SVG's own size. |
| `background` | Fill colour, e.g. `white` or `#ffffff`. Empty = transparent. |
| `includeDataUri` | Also return the PNG as a data URI (up to 1.5 MB). |
| `maxFileSizeMb` | Skip SVG files larger than this. |

Up to 200 images per run. Text in the SVG renders with DejaVu, Liberation or Noto fonts.

### Output

One row per input. `ok: true` rows have the PNG link (`pngUrl`), size and optional `dataUri`. `ok: false` rows carry an `error` and are not charged.

### Pricing

Pay per event: **$0.002 per image converted** plus a tiny $0.00005 start fee. No subscription. Failed images cost nothing.

### FAQ

**Does it run JavaScript inside the SVG?** No. Scripts are ignored, which keeps it fast and safe.

**Can I get a bigger PNG?** Set `width`, e.g. 1024 or 2048.

Built by [Broke to Built](https://broke2builtai.com). Questions: eli@broke2builtai.com.

# Actor input Schema

## `svg` (type: `string`):

One SVG document to convert, pasted as text. Leave empty if you only use SVG file URLs or Batch SVGs.

## `svgUrls` (type: `array`):

Public .svg file URLs to download and convert. One PNG per URL.

## `svgItems` (type: `array`):

Many SVG documents as text, one PNG each.

## `width` (type: `integer`):

Scale the PNG to this width, keeping the aspect ratio. 0 keeps the SVG's own size.

## `background` (type: `string`):

Fill behind the image, for example white or #ffffff. Empty keeps transparency.

## `includeDataUri` (type: `boolean`):

Add a ready data:image/png;base64 URI to each row (images up to 1.5 MB).

## `maxFileSizeMb` (type: `integer`):

Larger downloads are skipped, recorded and never charged.

## Actor input object example

```json
{
  "svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"240\" height=\"120\" viewBox=\"0 0 240 120\"><rect width=\"240\" height=\"120\" rx=\"16\" fill=\"#0f172a\"/><circle cx=\"60\" cy=\"60\" r=\"32\" fill=\"#38bdf8\"/><text x=\"110\" y=\"70\" font-family=\"sans-serif\" font-size=\"28\" fill=\"#f8fafc\">SVG to PNG</text></svg>",
  "svgUrls": [],
  "svgItems": [],
  "width": 0,
  "background": "",
  "includeDataUri": true,
  "maxFileSizeMb": 10
}
```

# Actor output Schema

## `results` (type: `string`):

One row per input. Export as JSON, CSV or Excel from the dataset view.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("eliai/svg-to-png").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("eliai/svg-to-png").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call eliai/svg-to-png --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,eliai/svg-to-png"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/nJflaW1y4DOmCPqgd/builds/2AZxxRzw2RWk1jIOo/openapi.json
