Chart.js to image: render a Chart.js chart as a PNG from a URL
Image-Charts turns a Chart.js configuration into a PNG image on its servers. You put the configuration in the c parameter of https://image-charts.com/chart.js/2.8.0, and the URL returns the image. Your side needs no browser, no canvas and no Node.js. Because it is a plain GET request, the URL works as the src of an <img> tag in an email, a PDF or a chat message. The API reads the Chart.js 2.8.0 configuration format.
https://image-charts.com/chart.js/2.8.0?bkg=white&c={"type":"pie","data":{"labels":["Email","Search","Direct"],"datasets":[{"data":[12,30,18]}]}}
That URL returns a 1000 × 600 pixel PNG: 500 × 300 by default, drawn at a pixel ratio of 2. The slices get the default colors because the dataset sets no backgroundColor. What this page says about the API's behavior was measured on the live API on 3 December 2026.
Overview
On this page, you'll learn:
- What is Chart.js
- How to use Chart.js configuration object as input for Image-Charts
- Which Chart.js version is supported, and how to adapt a Chart.js 3 or 4 configuration
- Which colors a chart gets when you set none
- How to customize your Chart.js image chart
- How to get the image from curl, Python and Node.js
Chart.js is the most popular open-source charting library. Image Charts supports Chart.js configuration object as input in the URL.
A Chart.js definition like the one below is represented in JavaScript Object Notation (JSON). Take a look at Chart.js documentation to discover all the available parameters.
{
"type": "line",
"data": {
"labels": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug"],
"datasets": [
{
"backgroundColor": "rgba(255,150,150,0.5)",
"borderColor": "rgb(255,150,150)",
"data": [-23, 64, 21, 53, -39, -30, 28, -10],
"label": "Dataset",
"fill": "origin"
}
]
}
}
Chart definition
To generate chart image using chart.js object format, put the Chart.js definition object in the URL using the chart (or c) query parameter, like this:
https://image-charts.com/chart.js/2.8.0?bkg=white&c={type:'line',data:{labels:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug'],datasets:[{backgroundColor:'rgba(255,150,150,0.5)',borderColor:'rgb(255,150,150)',data:[-23,64,21,53,-39,-30,28,-10],label:'Dataset',fill:'origin'}]}}
Image-Charts will take Chart.js configuration as input and render it on its world-wide distributed backends as an image.
Let's take another example, a pie chart with Chart.js will be something like:
{
"type": "pie",
"data": {
"datasets": [
{
"data": [84, 28, 57, 19, 97],
"backgroundColor": [
"rgba(255,99,132,0.5)",
"rgba(255,159,64,0.5)",
"rgba(255,205,86,0.5)",
"rgba(75,192,192,0.5)",
"rgba(54,162,235,0.5)"
],
"label": "Dataset 1"
}
],
"labels": ["Red", "Orange", "Yellow", "Green", "Blue"]
}
}
In order to render it as an image, we will use Image-Charts API:
https://image-charts.com/chart.js/2.8.0?bkg=white&c={%20%22type%22:%20%22pie%22,%20%22data%22:%20{%20%22datasets%22:%20[%20{%20%22data%22:%20[84,%2028,%2057,%2019,%2097],%20%22backgroundColor%22:%20[%20%22rgba(255,99,132,0.5)%22,%20%22rgba(255,159,64,0.5)%22,%20%22rgba(255,205,86,0.5)%22,%20%22rgba(75,192,192,0.5)%22,%20%22rgba(54,162,235,0.5)%22%20],%20%22label%22:%20%22Dataset%201%22%20}%20],%20%22labels%22:%20[%22Red%22,%20%22Orange%22,%20%22Yellow%22,%20%22Green%22,%20%22Blue%22]%20}%20}
Some JSON character (like #) do not work well inside URLs. It's recommended to always URL-encode the chart definition.
A definition with too many datasets, points, labels or texts is refused with a 400 HTTP status code. The limits are listed in Chart complexity limits.
Chart.js version
The Chart.js version is part of the path:
https://image-charts.com/chart.js/{version}
With version being one of:
2.8.0(documentation)- Need another version for your project? Contact us
Any other value in the path (3.2.0, 4.4.0, 2.9.4, latest) is not an API route. The request is redirected to the website and ends on a 404 HTML page instead of an image.
Chart.js 3 and 4 configurations
A configuration written for Chart.js 3 or 4 is still drawn, with an HTTP 200, but the options whose name changed in version 3 are ignored. For instance, options.plugins.legend has no effect and a scales.y block does not set the y axis. Pie, doughnut and polar area charts usually need no change, because their data block has the same shape in both versions.
To make a Chart.js 3 or 4 configuration render as intended, write these options the 2.8.0 way (Chart.js 3 migration guide):
options.plugins.legend→options.legendoptions.plugins.title→options.titleoptions.plugins.tooltip→options.tooltipsoptions.scales.x: {…}→options.scales.xAxes: [{…}], andscales.y→scales.yAxes: [{…}]scales.y.minandscales.y.max→yAxes: [{ ticks: { min, max } }]scales.y.beginAtZero→yAxes: [{ ticks: { beginAtZero: true } }]indexAxis: 'y'on a bar chart →"type": "horizontalBar"
Need Chart.js 3 or 4 rendered on your own servers instead? Server-side chart rendering: library or hosted API compares chartjs-node-canvas, the Highcharts export server, AG Charts and Image-Charts, with their licences and requirements.
Default colors
When a dataset sets no backgroundColor, Image-Charts fills it from a palette of seven colors, in this order:
#4d89f9(blue)#00b88a(green)#ff9f40(orange)#ff6384(pink)#9966ff(purple)#ffcc33(yellow)#c9cbcf(grey)

{
"type": "pie",
"data": {
"labels": ["#4d89f9", "#00b88a", "#ff9f40", "#ff6384", "#9966ff", "#ffcc33", "#c9cbcf"],
"datasets": [{ "data": [1, 1, 1, 1, 1, 1, 1] }]
},
"options": { "legend": { "position": "right" } }
}
How the palette is applied depends on the chart type:
- Pie and doughnut charts: one color per slice (arc segment). After the seventh slice the palette starts over, so slice 8 is blue again.
- Bar and line charts: one color per dataset. Every bar of the first dataset is blue, every bar of the second is green, and so on.
- Line charts are filled under the line by default. Add
"fill": falseto a dataset to draw only the line, and give each dataset alabel, otherwise the legend readsundefined.
Chart.js itself behaves differently. Its documented default color is rgba(0, 0, 0, 0.1), a light grey, in 2.8.0, in 3.2.0 for pie and doughnut arcs and in the current version. In the browser, a pie chart without backgroundColor therefore has grey slices, unless the Colors plugin of Chart.js 4 is enabled. The same configuration sent to Image-Charts gets the seven colors above.
To choose the colors yourself, set backgroundColor on the dataset, either one color for the whole dataset or an array with one color per slice or bar. Hex codes, rgb(), rgba() and color names all work, for instance "backgroundColor": ["#e8710a", "rgba(26,115,232,0.5)", "green"]. The pie chart example above sets five rgba() colors this way.
Chart size
Both the width and height of the chart output image can be specified in pixel using width and height query parameters. Default values are width=500 and height=300.
width and height each accept a value from 1 to 999 pixels, the same per-side maximum as chs on /chart. A larger value is rejected with a 400 HTTP status code and the IS_VALIDATION_ERROR error code in the x-ic-error-code response header.
Here is a 300x200 chart:
https://image-charts.com/chart.js/2.8.0
?width=300
&height=200
&bkg=white
&c={"type":"bar","data":{"labels":["January","February","March","April","May","June","July"],"datasets":[{"backgroundColor":"rgba(54,162,235,0.5)","borderColor":"rgb(54,162,235)","borderWidth":1,"data":[73,41,29,61,-65,59,38]}]},"options":{"legend":{"display":false}}}
Pixel ratio
Charts are drawn with a device pixel ratio of 2, so the output image is twice the requested size. The 300x200 chart above is a 600x400 pixel image.
The Chart.js devicePixelRatio option can lower this ratio. For instance, devicePixelRatio: 1 produces an image of exactly width x height pixels:
{
"type": "bar",
...
"options": {
...
"devicePixelRatio": 1
}
}
The option is applied only when it is a number no greater than 2 that leaves at least one pixel on each side of the image. Any other value is ignored and the chart is drawn with a ratio of 2.
Axis ticks
Each numeric, logarithmic, time or radial axis renders at most 1000 ticks. A configuration that needs more is rejected with a 400 HTTP status code and the IS_VALIDATION_ERROR error code in the x-ic-error-code response header. The x-ic-error-validation header names the axis, for instance The y-axis-0 axis would render more than 1000 ticks.
This y axis goes from 0 to 1000 in steps of 10, so it renders 101 ticks. With "stepSize": 1 it would need 1001 ticks and be rejected.
{
"type": "line",
...
"options": {
"scales": {
"yAxes": [{ "ticks": { "min": 0, "max": 1000, "stepSize": 10 } }]
}
}
}
To stay under the limit:
- on numeric and radial axes, raise
ticks.stepSize, narrowticks.minandticks.max, or setticks.maxTicksLimit - on time axes, raise
time.stepSizeor use a largertime.unit - on time axes whose
ticks.sourceislabelsordata, send fewer labels or points, or setticks.sourcetoauto - on logarithmic axes, narrow the range: they render 9 ticks per power of ten
- on category axes, send fewer labels, or narrow
ticks.minandticks.max
A category axis renders one tick per label between ticks.min and ticks.max. It has no limit of its own, but its labels are limited (see Chart complexity limits). All the axes of a chart render at most 11,000 ticks together. Past that, the x-ic-error-validation header reads The axes would render more than 11000 ticks together and names the axis that crossed the limit. Remove axes, or apply the remedies above.
Background color
Chart background color can be defined with the backgroundColor (or bkg) query parameter. Image charts accepts multiple color format:
- rgb:
bkg=rgb(255,255,120),backgroundColor=rgb(0,0,0) - named colors:
backgroundColor=red,bkg=white - url-encoded hex values:
bkg=%23ff00ff,backgroundColor=%23ffff00
Without bkg, the background is black at about 10% opacity (alpha 25 out of 255), so the PNG looks light grey on a white page and dark on a dark one. Set bkg=white for an opaque white background.
Here is a bubble chart with a near white background (bkg=%23FCFCFC):
bkg=%23FCFCFC
c={type:'bubble',data:{datasets:[{backgroundColor:'rgba(255,99,132,0.5)',borderColor:'rgb(255,99,132)',borderWidth:1,data:[{x:62,y:94,r:9.8,},{x:-62,y:-34,r:7.4,},{x:8,y:60,r:1.8,},{x:-44,y:59,r:9.4,},{x:64,y:46,r:6.8,},{x:16,y:-95,r:10.8,},{x:95,y:-80,r:1.8,},],},{"backgroundColor":"rgba(54,162,235,0.5)","borderColor":"rgb(54,162,235)",borderWidth:1,data:[{x:-15,y:-28,r:14.8,},{x:-31,y:-53,r:11,},{x:-70,y:-74,r:14,},{x:-48,y:-6,r:7,},{x:-82,y:34,r:13.6,},{x:-89,y:-71,r:16.8,},{x:15,y:-38,r:0.2,},]}]},"options":{"legend":{"display":false}}}
The same bubble chart with a black background expressed in rgb format (bkg=rgb(0,0,0)):
bkg=rgb(0,0,0)
chart={type:'bubble',data:{datasets:[{backgroundColor:'rgba(255,99,132,0.5)',borderColor:'rgb(255,99,132)',borderWidth:1,data:[{x:62,y:94,r:9.8,},{x:-62,y:-34,r:7.4,},{x:8,y:60,r:1.8,},{x:-44,y:59,r:9.4,},{x:64,y:46,r:6.8,},{x:16,y:-95,r:10.8,},{x:95,y:-80,r:1.8,},],},{"backgroundColor":"rgba(54,162,235,0.5)","borderColor":"rgb(54,162,235)",borderWidth:1,data:[{x:-15,y:-28,r:14.8,},{x:-31,y:-53,r:11,},{x:-70,y:-74,r:14,},{x:-48,y:-6,r:7,},{x:-82,y:34,r:13.6,},{x:-89,y:-71,r:16.8,},{x:15,y:-38,r:0.2,},]}]},"options":{"legend":{"display":false}}}
Encoding
To reduce the whole URL size and don't run into issues, chart definition can be encoded with encoding query parameter.
Accepted values are encoding=url and encoding=base64. Default values is encoding=url.
Encoding the URL in base64 (encoding=base64):
https://image-charts.com/chart.js/2.8.0
?encoding=base64
&bkg=white
&c=ewogIHR5cGU6ICdyYWRhcicsCiAgZGF0YTogewogICAgbGFiZWxzOiBbCiAgICAgIFsnRWF0aW5nJywgJ0Rpbm5lciddLAogICAgICBbJ0RyaW5raW5nJywgJ1dhdGVyJ10sCiAgICAgICdTbGVlcGluZycsCiAgICAgIFsnRGVzaWduaW5nJywgJ0dyYXBoaWNzJ10sCiAgICAgICdDb2RpbmcnLAogICAgICAnQ3ljbGluZycsCiAgICAgICdSdW5uaW5nJywKICAgIF0sCiAgICBkYXRhc2V0czogWwogICAgICB7CiAgICAgICAgbGFiZWw6ICdNeSBGaXJzdCBkYXRhc2V0JywKICAgICAgICBiYWNrZ3JvdW5kQ29sb3I6ICdyZ2JhKDI1NSwgOTksIDEzMiwgMC4yKScsCiAgICAgICAgYm9yZGVyQ29sb3I6ICdyZ2IoMjU1LCA5OSwgMTMyKScsCiAgICAgICAgcG9pbnRCYWNrZ3JvdW5kQ29sb3I6ICdyZ2IoMjU1LCA5OSwgMTMyKScsCiAgICAgICAgZGF0YTogWzI2LCA5LCA0MiwgMjMsIDQyLCAyNiwgMTBdLAogICAgICB9LAogICAgICB7CiAgICAgICAgbGFiZWw6ICdNeSBTZWNvbmQgZGF0YXNldCcsCiAgICAgICAgYmFja2dyb3VuZENvbG9yOiAncmdiYSg1NCwgMTYyLCAyMzUsIDAuMiknLAogICAgICAgIGJvcmRlckNvbG9yOiAncmdiKDU0LCAxNjIsIDIzNSknLAogICAgICAgIHBvaW50QmFja2dyb3VuZENvbG9yOiAncmdiKDU0LCAxNjIsIDIzNSknLAogICAgICAgIGRhdGE6IFs2LCA5OCwgMjcsIDU4LCA1MiwgMzksIDM1XSwKICAgICAgfSwKICAgIF0sCiAgfSwKICBvcHRpb25zOiB7CiAgICB0aXRsZTogewogICAgICBkaXNwbGF5OiB0cnVlLAogICAgICB0ZXh0OiAnQ2hhcnQuanMgUmFkYXIgQ2hhcnQnLAogICAgfSwKICB9LAp9Cg==
Basic URL encoding (encoding=url):
bkg=white
c={type:'polarArea',data:{datasets:[{data:[3,56,61,78,83],backgroundColor:['rgba(255,99,132,0.5)','rgba(255,159,64,0.5)','rgba(255,205,86,0.5)','rgba(75,192,192,0.5)','rgba(54,162,235,0.5)',]}]},options:{title:{display:true,text:'Chart.jsPolarAreaChart',}}}
encoding=url
Datalabels
Display labels on data for any type of charts
{
type: "bar",
data: {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [
{
label: "Dataset 1",
data: [-31, -70, -30, -33, -9, 14, -41]
},
{
label: "Dataset 2",
data: [73, 41, 29, 61, -65, 59, 38],
datalabels: {
labels: null,
font: {
size: "50"
}
}
}
]
},
options: {
datalabels: [["one"], ["two"], ["three"], ["four"], ["five"]],
responsive: true,
legend: {
position: "top"
}
}
}
{
type: "radar",
data: {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [
{
label: "Dataset 1",
data: [-31, -70, -30, -33, -9, 14, -41]
},
{
label: "Dataset 2",
data: [73, 41, 29, 61, -65, 59, 38],
datalabels: {
labels: null,
font: {
size: "50"
}
}
}
]
},
options: {
datalabels: [["one"], ["two"], ["three"], ["four"], ["five"]],
responsive: true,
legend: {
position: "top"
}
}
}
Fonts
Custom fonts are only available with Enterprise+ subscriptions
Custom fonts are the font families and font styles set in the Chart.js configuration. This covers every fontFamily and fontStyle option (including defaultFontFamily and defaultFontStyle) at any level (global, title, legend, ticks), as well as font.family and font.style of datalabels.
On other plans these options are ignored and the chart is drawn with the default font. The request still succeeds, whereas the icff and icfs parameters of /chart answer 401. Font sizes and colors apply on every plan.
Remove the watermark
You will receive an account_id and a secret_key upon signup. To authenticate your requests and thus remove the watermark, the whole query string must be signed with the ichm= query parameter. To learn more about how to sign Image-Charts API requests, check out Enterprise documentation section.
icac=account_id
ichm=generated_hash
Here is an example of a signed chart URL thus without a watermark. Observe the icacand ichm query parameter:
https://image-charts.com/chart.js/2.8.0
?bkg=white
&icac=documentation
&c=ewogIHR5cGU6ICdyYWRhcicsCiAgZGF0YTogewogICAgbGFiZWxzOiBbCiAgICAgIFsnRWF0aW5nJywgJ0Rpbm5lciddLAogICAgICBbJ0RyaW5raW5nJywgJ1dhdGVyJ10sCiAgICAgICdTbGVlcGluZycsCiAgICAgIFsnRGVzaWduaW5nJywgJ0dyYXBoaWNzJ10sCiAgICAgICdDb2RpbmcnLAogICAgICAnQ3ljbGluZycsCiAgICAgICdSdW5uaW5nJywKICAgIF0sCiAgICBkYXRhc2V0czogWwogICAgICB7CiAgICAgICAgbGFiZWw6ICdNeSBGaXJzdCBkYXRhc2V0JywKICAgICAgICBiYWNrZ3JvdW5kQ29sb3I6ICdyZ2JhKDI1NSwgOTksIDEzMiwgMC4yKScsCiAgICAgICAgYm9yZGVyQ29sb3I6ICdyZ2IoMjU1LCA5OSwgMTMyKScsCiAgICAgICAgcG9pbnRCYWNrZ3JvdW5kQ29sb3I6ICdyZ2IoMjU1LCA5OSwgMTMyKScsCiAgICAgICAgZGF0YTogWzI2LCA5LCA0MiwgMjMsIDQyLCAyNiwgMTBdLAogICAgICB9LAogICAgICB7CiAgICAgICAgbGFiZWw6ICdNeSBTZWNvbmQgZGF0YXNldCcsCiAgICAgICAgYmFja2dyb3VuZENvbG9yOiAncmdiYSg1NCwgMTYyLCAyMzUsIDAuMiknLAogICAgICAgIGJvcmRlckNvbG9yOiAncmdiKDU0LCAxNjIsIDIzNSknLAogICAgICAgIHBvaW50QmFja2dyb3VuZENvbG9yOiAncmdiKDU0LCAxNjIsIDIzNSknLAogICAgICAgIGRhdGE6IFs2LCA5OCwgMjcsIDU4LCA1MiwgMzksIDM1XSwKICAgICAgfSwKICAgIF0sCiAgfSwKICBvcHRpb25zOiB7CiAgICB0aXRsZTogewogICAgICBkaXNwbGF5OiB0cnVlLAogICAgICB0ZXh0OiAnQ2hhcnQuanMgUmFkYXIgQ2hhcnQnLAogICAgfSwKICB9LAp9Cg==
&encoding=base64
&ichm=c31c38d85cee460cb144828909d1deb2082ddb7b42e7d6713df93e9ad4507c65
JavaScript function (callbacks)
Image-Charts does not support Chart.js JavaScript function as value feature for reliability reasons.
Extensions
Image-Charts comes bundled with production battle-tested extensions.
Rounded bar charts
Examples
Bar chart below has 3 datasets and each bar has 10px rounded corners:
{
"type": "bar",
...
"options": {
...
"rectangleRadius": 10,
}
}
Code examples
Each example below sends the same pie chart configuration and saves the PNG to chart.png. All three were run against the API on 3 December 2026.
curl, which URL-encodes the configuration for you:
curl -G https://image-charts.com/chart.js/2.8.0 \
--data-urlencode 'bkg=white' \
--data-urlencode 'c={"type":"pie","data":{"labels":["Email","Search","Direct"],"datasets":[{"data":[12,30,18]}]}}' \
-o chart.png
Python, standard library only:
import json
import urllib.parse
import urllib.request
config = {
"type": "pie",
"data": {
"labels": ["Email", "Search", "Direct"],
"datasets": [{"data": [12, 30, 18]}],
},
}
url = "https://image-charts.com/chart.js/2.8.0?bkg=white&c=" + urllib.parse.quote(json.dumps(config))
urllib.request.urlretrieve(url, "chart.png")
Node.js, with the chart.js-image package (npm install chart.js-image):
const ChartJSImage = require('chart.js-image');
const chart = ChartJSImage()
.chart({
type: 'pie',
data: {
labels: ['Email', 'Search', 'Direct'],
datasets: [{ data: [12, 30, 18] }],
},
})
.backgroundColor('white')
.width(500)
.height(300);
console.log(chart.toURL()); // the image URL, ready for an <img> tag
chart.toFile('chart.png'); // Promise, writes the PNG
The same package also has toBuffer() and toDataURI(). The latter returns a data:image/png;base64,… string. In HTML, the URL goes straight into an image tag, URL-encoded:
<img src="https://image-charts.com/chart.js/2.8.0?bkg=white&c=%7B%22type%22%3A%22pie%22%2C%22data%22%3A%7B%22labels%22%3A%5B%22Email%22%2C%22Search%22%2C%22Direct%22%5D%2C%22datasets%22%3A%5B%7B%22data%22%3A%5B12%2C30%2C18%5D%7D%5D%7D%7D" alt="Pie chart of traffic sources: Email 12, Search 30, Direct 18" width="500" height="300">
FAQ
Which Chart.js version does Image-Charts support?
Image-Charts renders configurations written for Chart.js 2.8.0, the one version served by the https://image-charts.com/chart.js/2.8.0 path. Other versions in the path end on a 404 page. A Chart.js 3 or 4 configuration is drawn, but the options renamed in version 3 are ignored. Chart.js 3 and 4 configurations lists their 2.8.0 equivalents.
Why are my Chart.js pie chart slices grey when I set no backgroundColor?
In Chart.js, including 3.2.0, the default backgroundColor of a pie or doughnut arc is rgba(0, 0, 0, 0.1), a light grey. Set backgroundColor on the dataset with one color per slice, or turn on the Colors plugin in Chart.js 4. On Image-Charts, the same dataset gets a seven-color palette instead, starting with #4d89f9 and #00b88a.
Is there a server-side equivalent of toBase64Image()?
toBase64Image() is a method of a chart already drawn in the browser, and it returns a data URL. On a server there is no chart to call it on. Request the Image-Charts URL instead, whose response body is the PNG. If you need a base64 data URL, encode that response, or call toDataURI() of the chart.js-image Node.js package, which returns data:image/png;base64,….
Can I send the Chart.js configuration with a POST request?
No. /chart.js/2.8.0 answers GET requests, and a POST to it returns 404. Put the configuration in the c (or chart) query parameter, URL-encoded, or base64-encoded with encoding=base64.
What format and size is the image?
A PNG (image/png). The default size is width=500 and height=300; each side accepts 1 to 999. The chart is drawn at a pixel ratio of 2, so the default PNG is 1000 × 600 pixels, and devicePixelRatio: 1 gives exactly the requested size.
Why does my chart image have an image-charts.com mark in the corner?
Charts requested without a signature carry a small image-charts.com watermark at the top right. Paid plans remove it by signing the URL with icac and ichm, as explained in Remove the watermark.
Can I use JavaScript callbacks, such as a tick formatter?
No. The configuration is read as JSON (or a JavaScript object literal) and functions are not supported. Format your values before you send them, for instance in the labels.