Docs / Developer tools
Generated images API
Share images, code screenshots, avatars, placeholders and charts from a URL.
Pictures made from text, with no browser involved: link-preview (Open Graph) cards and syntax-coloured code images. Latin, Devanagari, Bengali, Gurmukhi, Gujarati, Odia, Tamil, Telugu, Kannada and Malayalam are shaped properly (conjuncts, vowel signs) and can be mixed in one line; other scripts come out as empty boxes. PNG by default; format=svg gives the same picture as an SVG whose text is drawn as outlines, so it needs no fonts where it is shown. Text and colours only: no images are fetched from anywhere. Each request counts as 10 against the rate limit.
https://api.dharun.devNo key needed for most600 units a minute, 3000 with a free keyThis page as MarkdownCode as an image
GET/v1/code-imagePOST
A code snippet as a window with syntax colouring. Up to 150 lines of 140 characters. PNGs are drawn at twice the pixel density for sharp text (very large ones at single). The language is guessed from the title's file extension or the code when not given, and reported in the X-Code-Language header.
Also takes POST: The code. Send it as text/plain, or as JSON {"text": "..."} with the other options beside it, up to 256 KB.
The answer returns the image itself; errors are JSON as everywhere else.
What you send here is never written to the log, and the answer is not cached.
| Parameter | Description |
|---|---|
codequery | The code (or POST it). |
languagequery | Language name or file extension, such as go, python, js, sql. |
titlequery | File name shown in the title bar. |
themequery | Default dark. One of: dark, light. |
lineNumbersquery | Show line numbers. One of: true. |
formatquery | Default png. One of: png, svg. |
curl
curl -o picture.png "https://api.dharun.dev/v1/code-image?language=go&title=main.go&code=package+main%0A%0Aimport+%22fmt%22%0A%0Afunc+main%28%29+%7B%0A%09fmt.Println%28%22%E0%AE%B5%E0%AE%A3%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AE%AE%E0%AF%8D%22%29%0A%7D&utm_medium=docs"HTML
<img src="https://api.dharun.dev/v1/code-image?language=go&title=main.go&code=package+main%0A%0Aimport+%22fmt%22%0A%0Afunc+main%28%29+%7B%0A%09fmt.Println%28%22%E0%AE%B5%E0%AE%A3%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AE%AE%E0%AF%8D%22%29%0A%7D&utm_medium=docs" alt="Code as an image">Try it here
Change the values and send the request from your browser. Needs JavaScript.
Result
Avatar with initials
GET/v1/avatar/{name}
A round (or square) tile with a person's initials, its colour fixed by the name, for user lists and comments. Initials in Indian scripts keep their vowel signs and conjuncts. SVG by default; a .png suffix or format=png gives PNG.
The answer returns the image itself; errors are JSON as everywhere else.
| Parameter | Description |
|---|---|
namepath, required | The name, in any script. The first letters of its first and last words are drawn. |
sizequery | Width and height in pixels, 16 to 1024. Default 128. |
shapequery | Default circle. One of: circle, square, rounded. |
bgquery | Background colour as hex, such as 2563eb. Default: picked from the name. |
fgquery | Letter colour as hex. Default white. |
initialsquery | Draw these letters instead (up to 4). |
formatquery | svg (default) or png. One of: svg, png. |
curl
curl -o picture.svg "https://api.dharun.dev/v1/avatar/Priya%20Raman?utm_medium=docs"HTML
<img src="https://api.dharun.dev/v1/avatar/Priya%20Raman?utm_medium=docs" alt="Avatar with initials">Try it here
Change the values and send the request from your browser. Needs JavaScript.
Result
Placeholder image
GET/v1/placeholder/{size}
A plain box with its size (or your text) in the middle, for mock-ups and layouts.
The answer returns the image itself; errors are JSON as everywhere else.
| Parameter | Description |
|---|---|
sizepath, required | WIDTHxHEIGHT, or one number for a square; each 8 to 4000. A .png suffix gives PNG. |
textquery | Text to show instead of the size, up to 80 characters. |
bgquery | Background colour as hex. Default dde3ea. |
fgquery | Text colour as hex. Default 556070. |
formatquery | svg (default) or png. One of: svg, png. |
curl
curl -o picture.svg "https://api.dharun.dev/v1/placeholder/600x400?utm_medium=docs"HTML
<img src="https://api.dharun.dev/v1/placeholder/600x400?utm_medium=docs" alt="Placeholder image">Try it here
Change the values and send the request from your browser. Needs JavaScript.
Result
Chart image from numbers
GET/v1/chartPOST
A bar, line, pie or sparkline chart as SVG or PNG, for emails, chat bots, READMEs and anywhere JavaScript charts cannot run. Axis values are written the Indian way (K, L, Cr). In the query: values=3,5,2 (repeat values for more series, with names to name them) and labels=Jan,Feb,Mar. Counts as 10 against the rate limit.
Also takes POST: A chart as JSON: {"type": "bar", "title": "...", "labels": [...], "series": [{"name": "...", "values": [...], "color": "2563eb"}], "width": 800, "height": 450}. Send it as text/plain, or as JSON {"text": "..."} with the other options beside it, up to 256 KB.
The answer returns the image itself; errors are JSON as everywhere else.
| Parameter | Description |
|---|---|
typequery | Default bar. One of: bar, line, pie, sparkline. |
valuesquery | Numbers separated by commas. Repeat the parameter for more series. |
labelsquery | Labels for the values, separated by commas. |
namesquery | A name for each series: repeated like values, or separated by commas. |
titlequery | Title above the chart. |
widthquery | Pixels, 40 to 3000. Default 800 (160 for a sparkline). |
heightquery | Pixels, 20 to 3000. Default 450 (40 for a sparkline). |
themequery | Default light. One of: light, dark. |
formatquery | svg (default) or png. One of: svg, png. |
curl
curl -o picture.svg "https://api.dharun.dev/v1/chart?type=bar&title=Sales%20by%20quarter&labels=Q1,Q2,Q3,Q4&values=12,19,9,15&utm_medium=docs"HTML
<img src="https://api.dharun.dev/v1/chart?type=bar&title=Sales%20by%20quarter&labels=Q1,Q2,Q3,Q4&values=12,19,9,15&utm_medium=docs" alt="Chart image from numbers">Try it here
Change the values and send the request from your browser. Needs JavaScript.
Result
Using an AI assistant? Connect the MCP server and it can call this API by itself. Want every endpoint on one bench? Open the playground.
Social preview image
GET/v1/og-image
A 1200 by 630 card for og:image and twitter:image: a title (set as large as fits in three lines, cut with an ellipsis beyond that), an optional subtitle of up to two lines, and a site name and tag along the bottom. The same URL always gives the same picture, so it can be used directly in a meta tag.
The answer returns the image itself; errors are JSON as everywhere else.
titlequery, requiredsubtitlequerysitequerytagquerythemequerybgqueryfgqueryaccentqueryformatquerycurl
HTML
Try it here
Change the values and send the request from your browser. Needs JavaScript.
Result