JSON to chart
JSON to chart is an API that turns data into a chart image (bar, line, pie, doughnut or radar). Send your numbers as JSON and get back a ready-to-use image for an email, a report or a Slack message, with nothing to design by hand.
How it works
You send the chart type, the labels (X-axis categories, or the name of each slice) and one or more series of numbers, and get back the generated image: PNG by default, base64-encoded inside a JSON response.
Since the input is always a data structure, this tool only accepts a JSON body (there's no "paste the raw file" mode).
All you need
- Your API key. Create it in your dashboard with "+ Create key". It's shown only once, so copy and save it.
- In your automation platform, an "HTTP Request" step (n8n, Make, Zapier, Pipedream… all have one).
- Your data as numbers: the tool does the rest.
How to use it in n8n (step by step)
In the HTTP Request node:
- Method:
POST - URL:
https://api.cofferdock.com/chart - Send Headers: on → add two:
x-api-key= your key, andContent-Type=application/json - Send Body: on → Body Content Type: JSON →
{ "type": "bar", "labels": ["Jan", "Feb", "Mar"], "series": [{ "name": "Sales", "data": [10, 20, 15] }] }
By default the response is already a JSON with the image as base64 inside the image field, so there's nothing else to change under Options → Response. If you'd rather get the image directly (to attach it as binary data), add "output": "binary" to the body and choose Response Format: File under Options → Response, same as other Cofferdock tools.
In Make (HTTP → Make a request module): same method and URL, Body type: Raw, Content type: JSON, with the same body.
Options (inside the JSON)
| Option | Default | What it does |
|---|---|---|
type | - | Required. Chart type: bar, line, pie, doughnut or radar. |
labels | - | Required. 1 to 50 strings: X-axis categories (bar/line) or the name of each slice/indicator (pie/radar). |
series | - | Required. 1 to 10 series, each { "name": "...", "data": [...] } with as many numbers as labels. pie/doughnut only support 1 series. |
title | - | Chart title (optional). |
width / height | 800 / 500 | Size in pixels (between 200 and 2000). |
format | png | png or svg. |
output | json | json (base64 image inside a JSON) or binary (the image directly). |
API overview
- Endpoint:
POST https://api.cofferdock.com/chart - Auth: header
x-api-key: YOUR_KEY. - Input:
application/jsonONLY. - Output: JSON with the base64 image by default; with
"output": "binary"it returns the image directly (image/pngorimage/svg+xmldepending onformat). - Engine: Apache ECharts in server mode (no browser, no canvas), rasterized to PNG with
sharpwhen needed. - Limits: 30 requests/min per IP. 1 chart = 1 credit, regardless of type or size.
Options
| Option | Default | Description |
|---|---|---|
type | - | Required. bar | line | pie | doughnut | radar (400 if not in the list). |
labels | - | Required. Array of 1 to 50 non-empty strings, up to 100 characters each. |
series | - | Required. Array of 1 to 10 { name?, data } objects. data must match labels' length and contain only finite numbers. name is optional (up to 100 characters; defaults to "Series N"). pie/doughnut: 400 if series.length > 1. |
title | - | Optional string, up to 200 characters. |
width / height | 800 / 500 | Number, clamped to [200, 2000]. |
format | png | png or svg. |
output | json | json or binary. |
Examples
curl (bar chart straight to PNG):
curl -X POST "https://api.cofferdock.com/chart" \
-H "x-api-key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"type":"bar","labels":["Jan","Feb","Mar"],"series":[{"name":"Sales","data":[10,20,15]}],"output":"binary"}' \
-o chart.png
JavaScript (Node 18+):
const r = await fetch('https://api.cofferdock.com/chart', {
method: 'POST',
headers: { 'x-api-key': 'YOUR_KEY', 'Content-Type': 'application/json' },
body: JSON.stringify({
type: 'pie',
title: 'Breakdown',
labels: ['A', 'B', 'C'],
series: [{ data: [40, 25, 35] }],
}),
});
const { image } = await r.json();
require('fs').writeFileSync('chart.png', Buffer.from(image, 'base64'));
Python:
import base64, requests
r = requests.post(
'https://api.cofferdock.com/chart',
headers={'x-api-key': 'YOUR_KEY', 'Content-Type': 'application/json'},
json={'type': 'line', 'labels': ['Jan', 'Feb', 'Mar'], 'series': [{'data': [10, 20, 15]}], 'output': 'binary'},
)
open('chart.png', 'wb').write(r.content)
Response with output=json (default)
{ "success": true, "image": "iVBORw0KGgoAAAANSUhEUgAA…", "mime_type": "image/png",
"meta": { "format": "png", "width": 800, "height": 500, "used": 12, "remaining": 488 } }
What you get back
By default, a JSON with the image as base64: handy for using it right away in the next step of your flow (for example, embedding it in an email as data:image/png;base64,…) with no extra steps. With "output": "binary" you get the image directly, useful when the next step expects a binary file.