MCP Server & API
Everything the editor does is scriptable. Render code images from Claude Code, Cursor, CI pipelines, or any MCP-capable agent — no API key, no sign-up, no rate limit to negotiate.
MCP server
A hosted Model Context Protocol server over streamable HTTP. Nothing to install or run locally — point your client at the URL and the tools appear.
https://codetoimage.com/mcp claude mcp add --transport http codetoimage https://codetoimage.com/mcp {
"mcpServers": {
"codetoimage": {
"url": "https://codetoimage.com/mcp"
}
}
} codex mcp add codetoimage -- npx -y mcp-remote https://codetoimage.com/mcp Tools
create_code_image Renders a snippet and returns the PNG inline, plus a permanent image URL and an editable share link.
Args — code, language, theme, background, padding, borderRadius, windowChrome, windowTitle, shadow, fontSize, lineNumbers, lineNumberStart, aspectRatio, format, scale
create_share_link Builds an editor link that opens with your code and styling, without rendering an image. Use when a human should fine-tune the result.
Args — same styling arguments as create_code_image
list_style_options Lists available themes, languages, and gradient presets so an agent can pick valid values.
Args — themeType (optional: dark or light)
REST API
One request in, an image out. POST
a JSON body or GET with query
parameters — both return PNG or SVG bytes directly, so you can hotlink the URL in a README or an
<img> tag.
curl -X POST https://codetoimage.com/api/image \
-H 'Content-Type: application/json' \
-d '{
"code": "const answer = 42;",
"language": "javascript",
"theme": "dracula",
"windowTitle": "answer.js"
}' \
--output code.png https://codetoimage.com/api/image
?code=const%20answer%20%3D%2042%3B
&language=javascript
&theme=dracula
&scale=2 Machine-readable schema at /api/openapi.json. Every accepted theme, language, font, and gradient is listed at /api/options.json.
Parameters
The same fields work in the API, the MCP tools, and share links. Only code is required.
| Field | Values | Notes |
|---|---|---|
code | string (required) | The source to render, up to 20,000 characters. |
language | enum | Syntax highlighting language. 37 supported. Default javascript. |
theme | enum | Syntax theme. 38 available. Default github-dark. |
format | png | svg | Output format. Default png. |
scale | 1 | 2 | 4 | 6 | PNG pixel density. Default 2. |
backgroundGradient | string | null | CSS linear-gradient(...), or null for a solid color. 16 presets. |
backgroundColor | hex | Solid background, used when backgroundGradient is null. |
backgroundVisible | boolean | Set false for a transparent frame. |
padding | 0–256 | Space around the code window, in px. Default 64. |
borderRadius | 0–48 | Window corner radius. Default 16. |
windowChrome | macos | macos-outline | macos-gray | windows | none | Title bar style. Default macos. |
windowTitle | string | Filename shown in the title bar. |
shadow | none | sm | md | lg | bottom | Window shadow. Default lg. |
borderStyle | none | solid | glass | Window border treatment. |
fontSize | 10–28 | Code font size in px. Default 14. |
lineNumbers | boolean | Show line numbers. Default false. |
lineNumberStart | integer | First line number. Default 1. |
tabSize | 1–8 | Spaces per tab. Default 2. |
aspectRatio | auto | 16:9 | 4:3 | 1:1 | Grow the frame to a fixed ratio. Default auto. |
Errors
Every 4xx and 5xx response is application/json
with the same three fields — never an HTML error page. Branch on
code, which is stable; the
error wording may change.
{
"error": "\"code\" is required (string, max 20000 chars)",
"code": "missing_code",
"hint": "Pass the snippet as the \"code\" field (POST body) or ?code= (GET)."
} | Code | Status | Meaning |
|---|---|---|
missing_code | 400 | No "code" field was supplied, or it was blank. |
invalid_state | 400 | The "s" share blob could not be decoded. |
invalid_json | 400 | The POST body was not a JSON object. |
render_failed | 500 | The renderer threw. Retry once before giving up. |
Typed as the Error schema in
/api/openapi.json.
Agent skill
Prefer skills over tool definitions? Install the whole workflow — rendering, share links, and style options — in one command.
npx skills add https://codetoimage.com Reads /.well-known/agent-skills/. You can also read SKILL.md or llms.txt directly.
Privacy
The web editor renders entirely in your browser — code you paste there never leaves your device. The API and MCP server do receive the snippet you send them; they render it statelessly and store nothing. As with any hosted service, don't send private or sensitive source code without authorization.
Prefer to do it by hand? The editor is free and needs no account.
Open the editor