{"id":89,"date":"2026-10-15T21:33:04","date_gmt":"2026-10-15T21:33:04","guid":{"rendered":"https:\/\/blog.skndan.com\/jsontoimg\/?p=89"},"modified":"2026-11-17T13:33:13","modified_gmt":"2026-11-17T13:33:13","slug":"why-i-built-a-json-to-image-api-instead-of-using-puppeteer","status":"publish","type":"post","link":"https:\/\/blog.skndan.com\/jsontoimg\/2026\/10\/15\/why-i-built-a-json-to-image-api-instead-of-using-puppeteer\/","title":{"rendered":"Puppeteer Alternative: Why I Built a JSON-to-Image API"},"content":{"rendered":"<p>Puppeteer will render a page. It will also leak memory at 3am. This is the founder note on why jsontoimg is a named-layer template API instead of a headless Chrome farm \u2014 not a product brochure.<\/p>\n<h2>Overview<\/h2>\n<p>Every developer who needs generated images hits the same fork in the road: spin up Puppeteer (or Playwright) and screenshot HTML, or pay for an image generation API. I went down the Puppeteer path first \u2014 and spent months paying for it in memory leaks, crashed workers, and quiet engineering hours. This is the story of why I gave up on the headless browser and built a JSON-to-image API instead, plus the real cost math that convinced me.<\/p>\n<h2>The Puppeteer Honeymoon Phase<\/h2>\n<p>Let me be fair: Puppeteer *feels* like the obvious choice at first. <code>npm install puppeteer<\/code> downloads a bundled Chromium, and you\u2019re generating images within the hour:<\/p>\n<pre><code>const puppeteer = require(&#39;puppeteer&#39;);\n\n(async () =&gt; {\n  const browser = await puppeteer.launch();\n  const page = await browser.newPage();\n  await page.setViewport({ width: 1200, height: 630 });\n  await page.goto(&#39;https:\/\/example.com\/og-template&#39;, { waitUntil: &#39;networkidle0&#39; });\n  await page.screenshot({ path: &#39;og-image.png&#39; });\n  await browser.close();\n})();\n<\/code><\/pre>\n<p>Fifty lines of code. No API key, no monthly fee, no vendor. For a one-off script that runs on your laptop, Puppeteer is genuinely the right tool. The problem starts the moment you need to generate images in *production*, at *volume* \u2014 which is exactly when the \u201cfree browser\u201d stops being free.<\/p>\n<h2>Where the Browser Stops Being Cheap<\/h2>\n<p>Here\u2019s what nobody mentions in the Puppeteer tutorial: every browser instance you spawn is a full Chromium process. That has real, measurable consequences:<\/p>\n<ul>\n<li><strong>Memory<\/strong>: a single Chromium instance consumes roughly <strong>80\u2013300 MB of RAM<\/strong> depending on page complexity, and a render can pin a CPU core for 1\u20133 seconds (<a href=\"https:\/\/medium.com\/@TheTechDude\/how-screenshot-apis-work-under-the-hood-architecture-deep-dive-faf941178c0d\">source: Medium architecture deep dive<\/a>).<\/li>\n<li><strong>Memory leaks<\/strong>: Chromium leaks. A well-documented story from the SnapRender team \u2014 they spent <strong>four months fighting Puppeteer OOM crashes<\/strong> before switching to an API. Their browser containers died every 50 requests, failed 2\u20133% of screenshots, and required 3\u20134 workers with recycling just to stay alive (<a href=\"https:\/\/snap-render.com\/blog\/eliminated-puppeteer-memory-issues\">source: SnapRender<\/a>).<\/li>\n<li><strong>Scaling ceilings<\/strong>: a single render server hits its limit at roughly <strong>10\u201320 concurrent renders<\/strong>. Beyond that you need horizontal scaling: queues, worker pools, health checks, crash watchdogs, and retry logic \u2014 all of which you build yourself (<a href=\"https:\/\/medium.com\/@TheTechDude\/how-screenshot-apis-work-under-the-hood-architecture-deep-dive-faf941178c0d\">source: Medium architecture deep dive<\/a>, <a href=\"https:\/\/urlbox.com\/guides\/kubernetes-website-screenshots\">Urlbox on Kubernetes scaling<\/a>).<\/li>\n<li><strong>Version drift<\/strong>: Chrome updates break your renders. Fonts render differently across environments. Cookie banners, network timeouts, and flaky <code>networkidle0<\/code> waits make output nondeterministic.<\/li>\n<\/ul>\n<p>The cost isn\u2019t the Chrome license \u2014 it\u2019s the <strong>engineering time<\/strong> spent keeping the browser farm alive. SnapRender\u2019s numbers are telling: their self-hosted setup cost <strong>$240\/month in infra plus 10\u201315 engineering hours per month<\/strong> just to babysit it. A cost comparison from Pagebolt estimates real-world Puppeteer operations at <strong>$15,000\u201320,000\/month<\/strong> when you include incident response and maintenance at 10M+ screenshots per month (<a href=\"https:\/\/pagebolt.dev\/blog\/puppeteer-vs-hosted-screenshot-api-cost\">source: Pagebolt<\/a>).<\/p>\n<h2>The Reframe: Screenshotting \u2260 Rendering<\/h2>\n<p>The turning point for me was realizing I had the wrong mental model. Puppeteer is a <strong>browser automation<\/strong> tool. It\u2019s unbeatable when you need to click through pages, fill forms, extract data, or screenshot an *existing website*.<\/p>\n<p>But most \u201cgenerate an image\u201d use cases are not that. Generating an OG card for a blog post, a product banner for SKU #4,721, or a certificate for a course graduate is <strong>data-in, image-out<\/strong> \u2014 a rendering problem, not a browsing problem. You\u2019re paying for a full JavaScript engine, layout engine, and network stack to draw text on a rectangle.<\/p>\n<p>The moment I separated those two mental models, the design for jsontoimg wrote itself.<\/p>\n<h2>What jsontoimg Does Differently<\/h2>\n<p>Instead of pointing a browser at HTML, jsontoimg is a <strong>JSON-driven renderer<\/strong>:<\/p>\n<p>1. <strong>Design a template<\/strong> \u2014 define the layout with placeholders for text, images, colors, and fonts.<\/p>\n<p>2. <strong>Send JSON data<\/strong> \u2014 one POST request with the values that change.<\/p>\n<p>3. <strong>Get an image back<\/strong> \u2014 a pixel-perfect PNG\/JPG, rendered directly.<\/p>\n<pre><code>POST \/api\/v1\/render?wait=60\n{\n  &quot;template&quot;: &quot;og-card&quot;,\n  &quot;format&quot;: &quot;png&quot;,\n  &quot;layers&quot;: {\n    &quot;title&quot;: { &quot;text&quot;: &quot;Why I Built a JSON-to-Image API&quot; },\n    &quot;author&quot;: { &quot;text&quot;: &quot;Balaji&quot; },\n    &quot;date&quot;: { &quot;text&quot;: &quot;2026-07-31&quot; }\n  }\n}\n<\/code><\/pre>\n<p>Because there\u2019s no browser process, there are no memory leaks, no worker pools, no Chrome updates, and no 80\u2013300 MB per render. A renderer is stateless and horizontally scales like any other API \u2014 batch an array of jobs, get an array of images back, or use webhooks for async delivery on large volumes. That\u2019s the entire pitch: <strong>JSON in, image out, nothing to maintain.<\/strong><\/p>\n<h2>When You Should Still Use Puppeteer<\/h2>\n<p>I don\u2019t want this to read as \u201cnever use Puppeteer\u201d \u2014 that would be dishonest. Keep the headless browser when:<\/p>\n<ul>\n<li>You need to screenshot <strong>existing live web pages<\/strong> (visual regression testing, website previews, monitoring).<\/li>\n<li>You need <strong>full browser interaction<\/strong> \u2014 login flows, form filling, multi-step automations before capture.<\/li>\n<li>Image generation is a <strong>side feature<\/strong> and you have the infra team to own it.<\/li>\n<\/ul>\n<p>If your real job is turning data into branded images \u2014 OG cards, product banners, certificates, ad creatives, personalized email graphics \u2014 a browser is the expensive way to do a simple thing. Those are exactly the use cases we\u2019ve built out as <a href=\"https:\/\/jsontoimg.com\/use-cases\/open-graph-images\/\">reference workflows<\/a>, from <a href=\"https:\/\/jsontoimg.com\/use-cases\/product-banners\/\">product banners at 10K SKUs<\/a> to <a href=\"https:\/\/jsontoimg.com\/use-cases\/certificates\/\">certificate generation<\/a>.<\/p>\n<h2>Key Takeaways<\/h2>\n<ul>\n<li>Puppeteer is a browser automation tool, not an image rendering tool \u2014 using it for templated images means paying browser overhead for a rendering job.<\/li>\n<li>The real cost of self-hosted rendering is engineering time: memory leak management, worker pools, scaling ceilings (~10\u201320 concurrent renders per server), and Chrome version drift.<\/li>\n<li>Real-world numbers: SnapRender dropped from $240\/mo + 10\u201315 eng hours to ~$99\/mo after switching; Pagebolt estimates $15\u201320K\/mo total at 10M+ screenshots.<\/li>\n<li>A JSON-driven render API removes the browser entirely: stateless, deterministic, horizontally scalable, nothing to babysit.<\/li>\n<li>Use Puppeteer for live-page screenshots and browser interactions; use a render API for templated, data-driven images.<\/li>\n<\/ul>\n<h2>FAQ<\/h2>\n<h3>Is Puppeteer cheaper than an image generation API?<\/h3>\n<p>Only while the volume is low and the machine is already paid for. Once you add memory headroom, font packages, concurrency limits, and the on-call time for a renderer that falls over at 3am, the per-image cost of self-hosted Chrome stops being the cheap option.<\/p>\n<h3>What breaks first when you self-host headless Chrome?<\/h3>\n<p>Memory and fonts. Each render holds a browser process, so concurrency is bounded by RAM, and a font missing from the container silently changes the output rather than failing.<\/p>\n<h3>When should I still use Puppeteer?<\/h3>\n<p>When the thing you need a picture of is a real web page \u2014 full-page screenshots, arbitrary third-party HTML, or CSS you do not control. A template-to-image API is for assets you designed; a browser is for pages you did not.<\/p>\n<h3>What is the difference between screenshotting and rendering?<\/h3>\n<p>A screenshot reproduces whatever a browser happened to paint, including layout drift and missing fonts. Rendering composites named layers you defined, so the same JSON produces the same pixels every time.<\/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\/blog\/build-vs-buy-image-generation\">Build vs buy image generation<\/a><\/li>\n<li><a href=\"https:\/\/jsontoimg.com\/blog\/html-to-image-api-vs-template-api\">HTML to image API vs template API<\/a><\/li>\n<li><a href=\"https:\/\/jsontoimg.com\/blog\/the-tech-stack-behind-jsontoimg\">The tech stack behind the renderer<\/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\/use-cases\/open-graph-images\/\">How to Auto-Generate Open Graph Images at Scale<\/a> (use case page)<\/li>\n<li><a href=\"https:\/\/jsontoimg.com\/use-cases\/product-banners\/\">Product Banners for Thousands of SKUs<\/a><\/li>\n<li><a href=\"https:\/\/jsontoimg.com\/use-cases\/certificates\/\">Certificate Generation with a Template-to-Image API<\/a><\/li>\n<li><a href=\"https:\/\/jsontoimg.com\/alternatives\/bannerbear\">jsontoimg vs Bannerbear: Which Image Generation API Is Right for You?<\/a><\/li>\n<li><a href=\"https:\/\/jsontoimg.com\/blog\/image-generation-api-pricing-comparison\">Image generation API pricing comparison<\/a><\/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>Puppeteer will render a page. It will also leak memory at 3am. This is the founder note on why jsontoimg is a named-layer template API instead of a headless Chrome farm \u2014 not a product brochure.<\/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,8,7,4,3,6],"class_list":["post-89","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-api","tag-founder-story","tag-headless-browser","tag-image-generation","tag-jsontoimg","tag-puppeteer"],"_links":{"self":[{"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/posts\/89","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=89"}],"version-history":[{"count":2,"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/posts\/89\/revisions"}],"predecessor-version":[{"id":356,"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/posts\/89\/revisions\/356"}],"wp:attachment":[{"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/media?parent=89"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/categories?post=89"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.skndan.com\/jsontoimg\/wp-json\/wp\/v2\/tags?post=89"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}