{"id":96,"date":"2026-10-15T21:33:02","date_gmt":"2026-10-15T21:33:02","guid":{"rendered":"https:\/\/blog.skndan.com\/jsontoimg\/?p=96"},"modified":"2026-11-17T13:33:12","modified_gmt":"2026-11-17T13:33:12","slug":"the-tech-stack-behind-jsontoimg","status":"publish","type":"post","link":"https:\/\/blog.skndan.com\/jsontoimg\/2026\/10\/15\/the-tech-stack-behind-jsontoimg\/","title":{"rendered":"The Tech Stack Behind a JSON-to-Image API"},"content":{"rendered":"<p>A JSON-to-image API is a job queue, a renderer, object storage, and signed URLs. This post walks the real paths: POST \/api\/v1\/render, POST \/api\/v1\/renders\/batch (max 50), GET \/api\/v1\/img\/\u2026 \u2014 not a fictional \/v1\/images API.<\/p>\n<h2>Overview<\/h2>\n<p>Every image generation API looks the same from the outside: you POST JSON, you get a PNG back. The interesting part is what happens between the request hitting the server and the bytes landing in your response. That\u2019s where the real engineering decisions live \u2014 and where most DIY implementations quietly fall apart.<\/p>\n<p>This is the technical deep dive behind jsontoimg: why it renders images the way it does, what alternatives we evaluated, how the request pipeline is structured, and the specific trade-offs that shaped the architecture. If you\u2019re building your own image pipeline (or just deciding whether to), this is the part nobody shows you.<\/p>\n<h2>The Core Problem: Rendering Is a Resource Problem<\/h2>\n<p>The moment you decide to generate images from data, you discover that the hard part isn\u2019t the API \u2014 it\u2019s the renderer. You have three honest options:<\/p>\n<table>\n<thead>\n<tr>\n<th>Approach<\/th>\n<th>Example tools<\/th>\n<th>Fidelity<\/th>\n<th>Cost to run<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Headless browser<\/td>\n<td>Puppeteer, Playwright<\/td>\n<td>Pixel-perfect HTML\/CSS<\/td>\n<td>High (Chromium is heavy)<\/td>\n<\/tr>\n<tr>\n<td>Vector rendering<\/td>\n<td>resvg, node-canvas, skia-canvas<\/td>\n<td>Great for flat layouts<\/td>\n<td>Low to medium<\/td>\n<\/tr>\n<tr>\n<td>Canvas\/raster libs<\/td>\n<td>Sharp, Canvas API<\/td>\n<td>Great for photos\/effects<\/td>\n<td>Low<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The temptation is to reach for a headless browser, because it gives you \u201creal\u201d HTML and CSS \u2014 and it\u2019s what GitHub itself uses to render Open Graph previews. But a headless browser is also a full browser: hundreds of megabytes of RAM per instance, CPU spikes, version drift, and the constant babysitting of zombie processes. At scale, that cost shows up on your infrastructure bill as clearly as on a line item.<\/p>\n<p>The CustomJS blog summed up the hidden cost well: the browser library is easy \u2014 the queueing, browser updates, sandboxing, retries, and monitoring around it are what actually eat your engineering time.<\/p>\n<h2>Why jsontoimg Doesn\u2019t Run a Headless Browser<\/h2>\n<p>The jsontoimg stack is built around <strong>deterministic template rendering<\/strong>, not HTML screenshots. That\u2019s a deliberate choice, and it changes everything downstream.<\/p>\n<p>When you send JSON to jsontoimg, the request doesn\u2019t describe a web page \u2014 it describes a <strong>layer stack<\/strong>: a background color, an image, some styled text, an overlay. Each layer maps to a renderable primitive. Because the input is constrained, the renderer can be constrained too.<\/p>\n<p>That gives us three properties a browser-based pipeline can\u2019t match:<\/p>\n<ol>\n<li><strong>Predictable memory<\/strong> \u2014 no tab, no DOM, no 60fps render loop. A render request uses a bounded, small amount of memory.<\/li>\n<li><strong>Speed<\/strong> \u2014 vector rasterization of a flat composition takes milliseconds, not seconds. No page load, no <code>networkidle2<\/code> wait, no font-loading race.<\/li>\n<li><strong>Deterministic output<\/strong> \u2014 the same JSON always produces the same pixels. With a browser you\u2019re one font-loading race away from a slightly different image on retry.<\/li>\n<\/ol>\n<p>This is the same trade-off that services like Bannerbear, Placid, and APITemplate.io make, and it\u2019s why template-based image APIs are so much cheaper per render than screenshot services.<\/p>\n<h2>The Rendering Pipeline<\/h2>\n<p>Here\u2019s the actual request flow inside jsontoimg:<\/p>\n<pre><code>POST \/api\/v1\/render (JSON payload)\n        \u2502\n        \u25bc\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502  API gateway     \u2502  auth, validation, rate limiting\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n         \u25bc\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502  Template engine \u2502  merge JSON data into template layers\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n         \u25bc\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502  Renderer        \u2502  vector rasterization \u2192 PNG\/JPG buffer\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n         \u25bc\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502  Storage         \u2502  object storage + CDN URL\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n         \u25bc\n   image URL \/ webhook\n<\/code><\/pre>\n<h3>Layer 1: Template Engine<\/h3>\n<p>Templates are stored as JSON schemas with typed layers \u2014 text, image, shape, group. The engine validates the incoming data against the schema, applies defaults, and resolves references (like <code>layers.product_name.text<\/code> or image URLs from your payload). This is a pure function: template + data \u2192 resolved composition. No side effects, no I\/O, trivially testable.<\/p>\n<h3>Layer 2: The Renderer<\/h3>\n<p>The resolved composition is rasterized using a native vector renderer \u2014 not a browser. For text, that means explicit font handling: fonts are bundled and subsetted server-side, so \u201cthe title wraps differently on the 3rd render\u201d is a problem we simply don\u2019t have. For images, it means decoding input images (logos, backgrounds, product shots), scaling them to the layer bounds, and compositing with alpha blending.<\/p>\n<p>Transparent PNG output is a first-class feature here \u2014 when the composition has no background layer, the alpha channel survives the pipeline. That\u2019s how you can generate overlay graphics and logos, not just full-bleed cards.<\/p>\n<h3>Layer 3: Storage and Delivery<\/h3>\n<p>Every generated image is persisted to object storage and served through a CDN with cache headers. That means:<\/p>\n<ul>\n<li>Renders are <strong>idempotent<\/strong> \u2014 requesting the same image twice returns the stored copy, not a fresh render<\/li>\n<li>Response times for repeat requests are CDN-fast<\/li>\n<li>Batch jobs don\u2019t hold webhook payloads hostage to slow clients<\/li>\n<\/ul>\n<p>The browser overhead is not a matter of opinion \u2014 <a href=\"https:\/\/pptr.dev\/guides\/docker\">Puppeteer&#39;s own containerisation guide<\/a> walks through the shared-memory limits, sandbox flags, and font packages a headless Chrome image needs before it will render reliably, which is a fair summary of the operational surface you inherit. Skipping it leaves the pipeline with a much smaller job: composite layers, write the file, and cache it. Delivery then follows ordinary web caching rules, where <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/Reference\/Headers\/Cache-Control\">Cache-Control<\/a> decides how long an edge keeps a rendered image and <a href=\"https:\/\/web.dev\/articles\/content-delivery-networks\">web.dev&#39;s CDN primer<\/a> explains why serving it from the edge matters more than shaving milliseconds off the render. Choosing what to write is the other half, and <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/Media\/Guides\/Formats\/Image_types\">MDN&#39;s image file type guide<\/a> is the reference we work from, and <a href=\"https:\/\/web.dev\/articles\/choose-the-right-image-format\">web.dev&#39;s format guidance<\/a> is why WebP rather than PNG is the sensible default for anything bound for a browser.<\/p>\n<h2>Sync vs Async: The Two-Path Design<\/h2>\n<p>A common mistake in image APIs is forcing everything through one mode. jsontoimg supports both:<\/p>\n<ul>\n<li><strong>Synchronous<\/strong> \u2014 for single images where you want the bytes in the response. Ideal for on-demand OG images and user-facing graphics.<\/li>\n<li><strong>Asynchronous with webhooks<\/strong> \u2014 for batches. POST an array of payloads, get a job ID, and receive a callback when the whole batch is done.<\/li>\n<\/ul>\n<p>The batch path uses a worker queue. Each item is a self-contained render job, so the queue scales horizontally: add workers, consume faster. This is the architecture that makes \u201cgenerate 10,000 product banners\u201d a plausible afternoon task instead of a weekend project. (See our <a href=\"https:\/\/jsontoimg.com\/use-cases\/product-banners\/\">product banner generator<\/a> use case for how that plays out in practice.)<\/p>\n<h2>What We Chose NOT to Build<\/h2>\n<p>Being an indie product means every layer you add is a layer you maintain. The stack deliberately stops at the edges:<\/p>\n<ul>\n<li><strong>No visual template editor<\/strong> \u2014 templates are JSON, versioned in your repo, reviewed in PRs. Designers can use Figma \u2192 export a spec; developers ship it. The getting started guide walks through the flow end to end.<\/li>\n<li><strong>No queuing monolith<\/strong> \u2014 the queue is a thin layer, not a platform. If you need orchestration, your existing pipeline (n8n, Make, your own workers) can call the API directly.<\/li>\n<li><strong>No browser emulation<\/strong> \u2014 if you genuinely need to screenshot a live web page, a screenshot API is the right tool. That\u2019s not this product, and that\u2019s fine.<\/li>\n<\/ul>\n<p>The discipline is the point: every \u201cno\u201d keeps the core render path fast, cheap, and predictable.<\/p>\n<h2>The Cost Math That Validated the Approach<\/h2>\n<p>The resource difference between browser-based and vector rendering isn\u2019t subtle. Rough numbers from operating this class of pipeline:<\/p>\n<table>\n<thead>\n<tr>\n<th>Metric<\/th>\n<th>Headless browser render<\/th>\n<th>jsontoimg-style render<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Memory per render<\/td>\n<td>100\u2013250 MB (Chromium)<\/td>\n<td>&lt; 50 MB<\/td>\n<\/tr>\n<tr>\n<td>Cold render latency<\/td>\n<td>1\u20135 s (page load + fonts)<\/td>\n<td>50\u2013300 ms<\/td>\n<\/tr>\n<tr>\n<td>Retry variance<\/td>\n<td>font\/timing races<\/td>\n<td>none (deterministic)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>That\u2019s the difference between \u201ca service that occasionally costs you real money\u201d and \u201ca function you can call in a loop without thinking.\u201d For teams generating images inside request paths \u2014 dynamic OG images, personalized emails, event tickets \u2014 that variance is what kills the UX. This is exactly why our <a href=\"https:\/\/jsontoimg.com\/use-cases\/open-graph-images\/\">Open Graph image<\/a> and <a href=\"https:\/\/jsontoimg.com\/use-cases\/event-tickets\">event ticket<\/a> use cases are built on the synchronous path.<\/p>\n<h2>Key Takeaways<\/h2>\n<ul>\n<li><strong>The renderer is the architecture.<\/strong> Everything else \u2014 API shape, pricing, reliability \u2014 follows from whether you render with a browser or with a vector rasterizer.<\/li>\n<li><strong>Constrained input enables constrained cost.<\/strong> JSON layer stacks render fast and predictably; HTML screenshots don\u2019t.<\/li>\n<li><strong>Two-path design matters.<\/strong> Sync for single images, async + webhooks for batches, and a worker queue that scales horizontally.<\/li>\n<li><strong>Storage is part of the product.<\/strong> Idempotent renders + CDN delivery mean repeat requests are cheap and fast.<\/li>\n<li><strong>Saying no is a feature.<\/strong> No browser, no visual editor, no queue monolith \u2014 every omission keeps the core path lean.<\/li>\n<\/ul>\n<h2>FAQ<\/h2>\n<h3>Why not run a headless browser for image generation?<\/h3>\n<p>A browser loads a full web engine per render, which means heavy memory, cold starts, and font surprises for every image. Compositing named layers directly removes that whole dependency and makes render time predictable.<\/p>\n<h3>What is the difference between the sync and async render paths?<\/h3>\n<p>The sync path renders and returns a single image in the request, which is what an Open Graph image generator or an interactive flow needs. The async path queues the job and reports back by webhook, which is what a batch of thousands needs.<\/p>\n<h3>Where are rendered images stored and served from?<\/h3>\n<p>Each render is written to object storage and served over a CDN, so the first unique request pays the render cost and every later request streams the stored file.<\/p>\n<h2>Related Resources<\/h2>\n<ul>\n<li><a href=\"https:\/\/jsontoimg.com\/blog\/lessons-from-launching-a-developer-first-image-api\">Lessons from launching a developer-first image API<\/a><\/li>\n<li><a href=\"https:\/\/jsontoimg.com\/product\/image-generation-api\">Template-based image generation API<\/a><\/li>\n<li><a href=\"https:\/\/jsontoimg.com\/blog\/batch-image-generation-generate-thousands-of-images\">Batch image generation API<\/a><\/li>\n<li><a href=\"https:\/\/jsontoimg.com\/docs\/guides\/sse-and-wait\">Wait and SSE docs<\/a><\/li>\n<li><a href=\"https:\/\/jsontoimg.com\/\">jsontoimg home<\/a> \u2014 the founder\u2019s take on the JSON-to-image approach<\/li>\n<li><a href=\"https:\/\/jsontoimg.com\/alternatives\/bannerbear\">jsontoimg vs Bannerbear: Which Image Generation API Is Right for You?<\/a> \u2014 how the template-based approach compares<\/li>\n<li><a href=\"https:\/\/jsontoimg.com\/use-cases\/open-graph-images\/\">Auto-Generate Open Graph Images at Scale<\/a> \u2014 the sync-path use case in production<\/li>\n<li><a href=\"https:\/\/jsontoimg.com\/use-cases\/\">Use Cases<\/a> \u2014 full list of what you can build on this stack<\/li>\n<\/ul>\n<p>Zoom out: <a href=\"https:\/\/jsontoimg.com\/blog\/json-to-image-converter\">How JSON-to-Image Conversion Works<\/a> maps the whole template, named-layer, and render-job architecture.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A JSON-to-image API is a job queue, a renderer, object storage, and signed URLs. This post walks the real paths: POST \/api\/v1\/render, POST \/api\/v1\/renders\/batch (max 50), GET \/api\/v1\/img\/\u2026 \u2014 not a fictional \/v1\/images AP<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[5,16,15,7,4,3,14],"class_list":["post-96","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-api","tag-architecture","tag-behind-the-build","tag-headless-browser","tag-image-generation","tag-jsontoimg","tag-tech-stack"],"_links":{"self":[{"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/posts\/96","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/comments?post=96"}],"version-history":[{"count":2,"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/posts\/96\/revisions"}],"predecessor-version":[{"id":355,"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/posts\/96\/revisions\/355"}],"wp:attachment":[{"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/media?parent=96"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/categories?post=96"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/tags?post=96"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}