Docs › Developer tools
Generated images API
Social preview images and code screenshots 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.
Code 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.
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"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" alt="Code as an image">Result
Using an AI assistant? Connect the MCP server and it can call this API by itself.
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.
titlequery, requiredsubtitlequerysitequerytagquerythemequerybgqueryfgqueryaccentqueryformatquerycurl
HTML
Result