JSONtoIMG

Blog

  • Next.js OG Image: @vercel/og ImageResponse vs a Template API

    A Next.js OG image has two good implementations, and they fail in different places. ImageResponse generates the image inside your app. A template API signs a URL and lets another service render it. Pick by who edits the layout and how complex it is, not by which demo looks nicer.

    Option 1: opengraph-image and ImageResponse

    Next.js supports an opengraph-image file convention and the ImageResponse constructor, which turns JSX and CSS into a PNG at 1200 by 630 by default. It runs inside your deployment with no extra service.

    The documented limits matter: only flexbox and a subset of CSS properties work, display: grid will not, and the bundle, including fonts and images, is capped at 500KB. The layout lives in your repo, so a designer's change is an engineer's pull request.

    Option 2: sign a URL from a template

    import type { Metadata } from "next";
    
    export async function generateMetadata({ params }): Promise<Metadata> {
      const post = await getPost((await params).slug);
      const { url } = await client.signImageUrl({
        template: process.env.OG_TEMPLATE_ID!,
        format: "png",
        layers: { headline: { text: post.title } },
      });
      return {
        openGraph: { images: [{ url, width: 1200, height: 630, alt: post.title }] },
      };
    }
    

    generateMetadata renders the tag into the server HTML. The designer edits the template in the editor; your code only sends the title. The signed URL contains the pinned template version, so a design change never alters a card that is already live.

    How to choose

    Question ImageResponse Template API
    Is the layout simple text on a gradient? Fits Fits
    Does it need grid, many fonts, or large images? Hits the documented limits Fits if the editor can draw it
    Does a designer edit it? Needs an engineer Edits in the editor
    Does it add a service dependency? No Yes
    Is cost per image zero? Compute only One credit per unique URL

    The honest default

    Start with ImageResponse if you have one layout, one engineer, and no designer in the loop. Move to a template when the second layout or the first design request arrives. The cutover is small: replace the opengraph-image file with the generateMetadata function above.

    Implementation detail and WordPress are in Sign Open Graph Image URLs in Next.js and WordPress. The pipeline and debugging live in the Open Graph image generator guide.

    FAQ

    How do I generate a dynamic OG image in Next.js?

    Use the opengraph-image file convention with ImageResponse to render JSX to a PNG in your app, or return a signed template-API URL from generateMetadata.

    What are the limits of Next.js ImageResponse?

    Next.js documents support for flexbox and a subset of CSS properties, no display: grid, and a 500KB bundle limit that includes fonts, images, and other assets.

    Does jsontoimg replace ImageResponse?

    It is an alternative. ImageResponse keeps the layout in code with no extra service. jsontoimg moves the layout into an editor so a designer can change it without a deploy.

    What does a template API cost per OG image?

    One credit for the first unique URL fetched, and zero for repeat fetches of the same title. Minting the signed URL is free.

    Related Resources

  • WordPress OG Image Automation from Post Titles

    WordPress Open Graph images usually mean a featured image someone remembered to upload. The jsontoimg plugin replaces that step: it mints a signed image URL from the post title, so every post gets a share card without a design-tool export. This guide to WordPress OG image automation covers the three entry points and the one trap that breaks previews.

    Install

    Download jsontoimg.zip from the plugin releases, upload it under Plugins, and activate it. It needs WordPress 6.6 and PHP 7.4. Paste an API key under Settings, then jsontoimg, and run Test connection. The key stays in the options table and never appears in frontend HTML.

    Option 1: the Gutenberg block

    Add the jsontoimg block, pick a template, and fill the layer fields. The preview uses the signed URL. Set as Featured Image downloads the render into the Media Library and assigns it as the post thumbnail, which gives themes and SEO plugins a normal featured_media to read. The post type must support featured images; WordPress documents the underlying call as set_post_thumbnail.

    Option 2: the shortcode

    
    

    layers is JSON and template is its own attribute. WordPress explains how these are registered in add_shortcode.

    Option 3: a wp_head tag for every post

    To set og:image for all posts, hook wp_head:

    add_action( 'wp_head', function () {
      if ( ! is_singular( 'post' ) ) { return; }
    
      $url = jsontoimg_sign_url( 'DESIGN_ID', [
        'format' => 'png',
        'layers' => [ 'headline' => [ 'text' => get_the_title() ] ],
      ] );
      if ( is_wp_error( $url ) ) { return; }
    
      printf( '<meta property="og:image" content="%s" />' . "\n", esc_url( $url ) );
      printf( '<meta property="og:image:alt" content="%s" />' . "\n", esc_attr( get_the_title() ) );
    } );
    

    jsontoimg_sign_url returns a URL string or a WP_Error, and the plugin caches minted URLs in transients, so a page view does not mint or bill again.

    The duplicate-tag trap

    Many SEO plugins already print an og:image. The Open Graph protocol says that when a tag repeats, the first one from top to bottom wins. Your snippet loses if the plugin's tag prints earlier. Either turn off the plugin's image output, or hook wp_head with an earlier priority.

    Logo and photo layers

    An image_url layer must be a public https file ending in .png, .jpg, .jpeg, or .webp, or a path from the jsontoimg Assets library. A placeholder CDN URL with no file extension fails at render time. Use a file from the Media Library.

    Cost

    Minting is free. The first unique fetch of each URL bills one credit, and later fetches are cache hits. A post whose title never changes costs one credit total. The wider picture is in the Open Graph image generator guide, and WordPress internals are in the block editor handbook.

    FAQ

    How do I add Open Graph images to WordPress posts automatically?

    Install the jsontoimg plugin, then print an og:image tag in wp_head from jsontoimg_sign_url using the post title. Every post gets a unique card with no manual export.

    Why does my WordPress post show the wrong share image?

    Usually two og:image tags are printed. The Open Graph protocol gives the first tag priority, so an SEO plugin's tag can override yours. Disable one of them.

    Does the WordPress plugin expose my API key?

    No. The key is stored in the options table and used server-side to mint the signed URL. Only the signed URL appears in the HTML.

    Can I set the featured image from the render?

    Yes. The block has a Set as Featured Image button that downloads the render into the Media Library and assigns it to the post.

    Related Resources

  • OG Image Not Showing? A Debug Checklist for Blank Previews

    If your OG image is not showing, this debugger checklist works from the crawler's side, because that is where a blank preview is decided. A social network fetches your page, reads the tags, fetches the image URL once, and caches whatever came back. Work through the steps in order and stop at the first failure.

    1. Check the tags in the raw HTML

    Run curl -s https://example.com/post | grep og:. If the tags are missing, they are being added after the page loads. The Open Graph protocol places them in the <head> of the served document, so render them on the server. In Next.js, generateMetadata does this.

    2. Check the image URL is absolute

    og:image should be a full https URL, not /images/card.png. Duplicate tags are allowed, but ogp.me states that the first tag from top to bottom wins on conflict, so a leftover tag from an SEO plugin can override yours.

    3. Fetch the image the way a crawler does

    curl -sI "https://app.jsontoimg.com/api/v1/img/<design-id>?headline=Hello&version=1&sig=..."
    

    You want 200 and an image Content-Type (MDN reference). Anything else maps to a row in the table below.

    4. Read the status code

    Status Meaning for a signed jsontoimg URL Fix
    200 Image served Problem is cache or tags; go to step 6
    503 with Retry-After First render still running Request it again; crawlers retry, but warm the URL after publishing
    401 Signature does not match the query string A proxy or CMS re-encoded a parameter; use the minted url verbatim
    400 Duplicate query key, such as two headline parameters Remove the duplicate before the URL reaches the page
    402 Workspace is out of image quota Buy a prepaid pack or upgrade; renders stop at quota

    5. Rule out blocked crawlers

    If the page or image sits behind a login, a staging password, or a robots.txt rule that disallows the crawler, the fetch fails before it reaches the image. Test from a network outside your VPN.

    6. Re-scrape and bust the cache

    Networks cache previews. After a fix, re-fetch in the Facebook Sharing Debugger or the LinkedIn Post Inspector. If the old image persists, change the image URL itself. A signed jsontoimg URL changes whenever the title or version changes.

    7. Add the alt text

    The protocol asks for og:image:alt next to og:image. It does not fix a blank card, but it is on the same checklist for a reason.

    The end-to-end design of the flow is in the Open Graph image generator guide.

    FAQ

    Why is my OG image not showing?

    The most common causes are tags added after page load, a relative image URL, an image URL that returns a non-200 status to the crawler, or a cached preview from before the fix.

    What does a 503 on a signed jsontoimg URL mean?

    The first render of that exact URL is still running. The response carries a Retry-After header, and crawlers and the Sheets and Airtable add-ons retry on it.

    Why does a signed URL return 401?

    The signature covers the query string. If anything re-encodes, reorders, or edits a parameter, verification fails with 401 and no render happens.

    How do I refresh a cached share preview?

    Re-scrape the page in the Facebook Sharing Debugger or LinkedIn Post Inspector. If the cached image sticks, change the image URL, for example by bumping the template version.

    Related Resources

  • Open Graph Image Generator: Per-Page Cards Without Hand Exports

    An Open Graph image generator turns each page's title and data into a share card, so you stop exporting one image per post by hand. The hard part is not drawing the card. It is serving a URL that a social crawler will accept on its first try, for every page, without an API key in the HTML.

    What the Open Graph protocol requires

    The Open Graph protocol names four required properties for every page: og:title, og:type, og:image, and og:url. It also says that a page specifying og:image should specify og:image:alt, and defines og:image:width and og:image:height. Tags go in the <head> of server-rendered HTML.

    Three ways to produce the image

    Approach Layout lives in Who edits the layout Limits
    Hand export from a design tool A design file Designer One export per page
    Code, such as Next.js ImageResponse Your repo Engineer Flexbox and a CSS subset, 500KB bundle
    Template API with signed URLs An editor template Designer What the editor can draw

    Hand export stops scaling at the tenth post. Code scales, but every layout tweak is a deploy. The template route keeps the designer in charge of the canvas and the engineer in charge of the payload. The Next.js trade-off is covered in Next.js OG Image: ImageResponse or a Template API?.

    The signed-URL flow

    1. Design a 1,200 by 630 template and name a headline layer. 1,200 by 630 is the default size of Next.js ImageResponse.
    2. When a page renders, call POST /api/v1/img/sign with the template, format, and layer values. Minting costs no credit.
    3. Put the returned url in og:image.
    4. The crawler fetches it with no key. The first unique URL renders and bills one credit; the same title again streams the stored file.
    const { url } = await client.signImageUrl({
      template: "<design-id>",
      format: "png",
      layers: { headline: { text: post.title } },
    });
    

    If the first render is still running, jsontoimg responds 503 with Retry-After, and crawlers retry. A tampered query string fails signature verification with 401. The full failure list is in OG Image Debugger Checklist.

    Checklist before you ship

    Where to go next

    FAQ

    What is an Open Graph image generator?

    A tool that builds the share-card image for each page from its title and data, then serves it as the og:image URL. jsontoimg does this with one template and signed URLs, so no API key reaches the page.

    What size should an Open Graph image be?

    1,200 by 630 pixels is the default size in Next.js ImageResponse and a common design target. Declare it with og:image:width and og:image:height so crawlers do not have to guess.

    Do I need og:image:alt?

    The Open Graph protocol says a page that specifies og:image should also specify og:image:alt, a description of what is in the image.

    How much does it cost to generate Open Graph images?

    Minting a signed URL is free. The first unique fetch of each URL costs one credit, and repeat fetches of the same title are served from storage at no extra credit.

    Related Resources

  • Build vs Buy Image Generation: The Hidden Cost of Puppeteer

    Build vs buy image generation is mostly a question about what you are willing to be on call for. A script that screenshots a page takes an afternoon. A renderer that stays up for two years is a different project, and the gap between those two is where the cost hides.

    What you own when you build

    The first version is a browser, a page, and a screenshot call, as in Chrome's Puppeteer guide. Then the list grows:

    Component What it means in practice
    Browser binary Puppeteer and Playwright both download and pin browser builds, so upgrades are your change window
    Fonts Missing fonts on the server render as fallback glyphs, and the bug only shows in production
    Load timing Deciding when a page is ready is a heuristic you tune per template
    Concurrency Browsers are heavy processes; a burst of renders needs a queue and a pool
    Storage and caching Rendered files need a bucket, cache headers, and cleanup
    Signed URLs <img> and og:image cannot carry a secret, so you build and verify signatures yourself
    Retries and webhooks Slow renders need a 503 and Retry-After path, and completion callbacks need idempotency
    The layout Every design change is a code change and a deploy

    None of these is hard alone. Together they are a product that nobody was hired to maintain.

    What you give up when you buy

    Control. A template API draws what its editor can draw, so arbitrary CSS and live-page capture are out of scope. You also take on a vendor, and your layer names become a contract; export your templates and keep the payload schema in your own repo.

    When building is the right call

    • The layout is the product, such as a screenshot service or a design tool.
    • You already operate headless browsers for another purpose and have the monitoring in place.
    • Volume is tiny and stable, and no designer will ever touch the output.
    • You need HTML features no editor offers.

    When buying is the right call

    • One layout repeats across records: Open Graph cards, certificates, product banners, email heroes.
    • A non-engineer edits the design.
    • Renders must be reliable at a burst, such as a registration list closing or a catalog price change.

    jsontoimg covers the second list with POST /api/v1/render, signed URLs, 50-job batches, and webhooks. Prices for it and seven other tools are in Image Generation API Pricing. The technical comparison of the two approaches is in HTML to Image API vs Template API.

    FAQ

    Is it cheaper to build an image generation service myself?

    The first version is cheaper to start. Running it is where costs accumulate: browser upgrades, fonts, concurrency, storage, signed URLs, and every layout change shipping as a deploy.

    When should I run my own headless Chrome?

    When the layout is the product, when you already operate browsers and monitor them, or when you need arbitrary HTML that no template editor supports.

    What is the main risk of buying?

    Lock-in on layer names and editor capability. Keep your payload schema in your own repository so a migration means rebuilding templates, not rewriting every caller.

    Can I migrate from Puppeteer to a template API gradually?

    Yes. Move one repeating layout first, such as Open Graph cards, behind the API and keep the screenshot script for pages that need arbitrary HTML.

    Related Resources

  • Image Generation API Pricing Comparison: 8 Template Tools (2026)

    Image Generation API Pricing: 8 Programmatic Tools Compared (2026)

    Important Scope Note: This comparison covers Template-Based and Programmatic Image Generation APIs (rendering structured JSON data into branded templates, OG cards, certificates, and PDFs via REST/SDKs). It does not cover generative AI prompt engines (such as Midjourney, DALL-E, or Stable Diffusion). If you are building automated product graphics or document workflows from application data, this breakdown is for you.

    Image generation API pricing is quoted in monthly subscriptions, credit allotments, and mixed pools, making direct comparison difficult. To establish an honest baseline, this image generation API pricing comparison normalizes eight programmatic image APIs by cost per 1,000 images at their entry tiers, highlights where credit pools hide hidden costs, and details high-volume pricing curves.

    Entry Tier: Normalized Cost per 1,000 Images

    Tool Entry Plan Included Volume Cost / 1,000 Images Credit Pool Type
    RenderForm $19/mo 1,000 $19.00 Dedicated image/PDF credits
    APITemplate.io $29/mo (annual) 1,500 $19.33 Mixed image + PDF
    Orshot $39/mo 1,500 $26.00 Mixed image + PDF + video seconds
    Templated $29/mo 1,000 $29.00 Mixed image + video
    DynaPictures $29/mo 1,000 $29.00 Mixed image + video
    jsontoimg Starter $29/mo 1,000 $29.00 Dedicated stills & PDF only
    Placid $19/mo 500 $38.00 Mixed (PDF costs 2 credits)
    Bannerbear $49/mo 1,000 $49.00 Mixed image + video credits

    Data reflects published pricing as of late 2026. Entry tiers represent the lowest entry cost for automated API access.

    Where jsontoimg Is Cheaper — And Where It Is Not

    At the absolute entry tier, RenderForm ($19.00/1k) and APITemplate.io ($19.33/1k) have lower upfront costs than jsontoimg Starter ($29.00/1k). However, real-world economics change significantly based on volume, burstiness, and credit expiration:

    1. Volume Scaling: As render counts increase, jsontoimg's unit cost drops dramatically:
      • Pro Plan: $59/mo for 5,000 images ($11.80 per 1,000)
      • Scale Plan: $129/mo for 15,000 images ($8.60 per 1,000 or ~$0.0086/image)
    2. Prepaid Packs with Zero Expiration: For seasonal or variable workloads, monthly subscriptions force you to pay for unused credits. jsontoimg offers non-expiring prepaid packs:
      • 250 images: $5 one-time ($0.020/image)
      • 500 images: $10 one-time ($0.020/image)
      • 750 images: $15 one-time ($0.020/image)

    4 Hidden Factors That Change Real API Costs

    1. Mixed Media Credit Dilution

    Platforms with "mixed" credit pools (like Bannerbear, Orshot, and Templated) allow you to generate video or animations. But because video consumes credits rapidly (e.g. 1–2 credits per video second), running a small video test can consume hundreds of credits meant for your static social cards or certificates. At jsontoimg, credit pools are strictly reserved for stills and PDFs.

    2. Multi-Page PDF Costs

    Generating PDFs is essential for certificates, invoices, and event badges. In Placid, generating a 1-page PDF costs 2 credits. In jsontoimg, 1 credit equals 1 PDF page, making document generation 50% more efficient.

    3. Failed Render Deductions

    In some legacy tools, jobs that fail after processing has initiated still consume quota. In jsontoimg, failed jobs never deduct credits. If you hit your quota limit, the API returns HTTP 402 Payment Required rather than billing unpredictable overage fees.

    4. Over quota behavior

    Some providers automatically charge steep per-1,000 credit overage fees. jsontoimg gives you full control: use prepaid packs as non-expiring overflow, or upgrade tiers on your schedule.

    Detailed Competitor Reviews

    For full feature-by-feature and payload breakdowns, visit our dedicated comparison pages:

    Related Resources

    Frequently Asked Questions

    How much does an image generation API cost?

    Entry plans range from $19/mo to $49/mo for 500 to 1,500 images ($19 to $49 per 1,000 images). High-volume plans drop costs below $0.01 per image. jsontoimg Starter is $29/mo for 1,000 images, and prepaid packs are $0.020 per image.

    Which programmatic image generation API is the cheapest?

    At entry tiers, RenderForm ($19/mo) and APITemplate.io ($29/mo annual) offer the lowest starting prices. At higher volume (5,000+ images), jsontoimg Pro ($11.80/1k) and Scale ($8.60/1k) provide superior economies of scale.

    Do prepaid credits expire?

    At jsontoimg, prepaid packs ($5 for 250, $10 for 500, $15 for 750) never expire. They remain on your account permanently and act as overflow protection on monthly plans.

    What is the difference between template-based APIs and AI image generators?

    Template-based image APIs (like jsontoimg) render predictable, deterministic graphics by injecting dynamic data (names, prices, dates, QR codes) into branded visual templates. Generative AI tools (Midjourney, DALL-E) produce unpredictable images from natural language text prompts and cannot guarantee brand consistency.

    Get 25 free images →

  • HTML to Image API vs Template API: Which Should You Use?

    An HTML to image API renders markup in a browser engine and screenshots the result. A template API fills named layers on a design drawn in an editor. Both turn data into a picture; the difference is who can change the layout after launch, and what that costs you.

    What an HTML to image API gives you

    Full CSS and a real browser. Puppeteer controls Chrome or Firefox over the DevTools Protocol or WebDriver BiDi, and Playwright takes screenshots of a page or a single element. Hosted services such as HTMLCSStoImage wrap that approach: send HTML and CSS, or a URL, and receive an image. If the thing you need to capture already exists as a web page, this is the shortest path.

    Where it costs you

    The layout lives in code. A designer who wants a bigger headline files a ticket, an engineer edits markup, and the change ships with a deploy. You also own font loading, wait-for-network timing, and the browser itself.

    The lightweight variant has its own ceiling. Next.js documents that ImageResponse supports only flexbox and a subset of CSS properties, that display: grid will not work, and that the bundle is capped at 500KB including fonts and images. Satori, the engine underneath, publishes the exact list of supported properties.

    What a template API gives you

    A designer draws the layout once and names the layers that change. Your code sends JSON:

    {
      "template": "<design-id>",
      "format": "png",
      "layers": { "headline": { "text": "Ship the new pricing page" } }
    }
    

    Unknown layer names fail with a 422, and production pins a template version, so a layout edit never rewrites an image you already published. The cost is range: you can only produce what the editor can draw. There is no arbitrary HTML, no web components, and no capturing a live URL.

    How to choose

    You need Better fit
    A screenshot of a live, public page HTML to image API
    Arbitrary CSS, grid, or web components HTML to image API
    A different layout on every request HTML to image API
    One layout, thousands of records Template API
    A designer changing the layout without a deploy Template API
    A strict payload that rejects typos Template API

    If the layout stays the same and only the data changes, use a template API. If the page itself is the content, screenshot it. The longer account of why one team left Puppeteer is in Why I Built a JSON-to-Image API Instead of Puppeteer.

    FAQ

    What is an HTML to image API?

    A service that loads HTML and CSS, or a URL, in a headless browser and returns a screenshot as PNG, JPG, or WebP. You control the markup directly, which makes it flexible and puts layout ownership with developers.

    When should I use a template API instead?

    Use a template API when one layout repeats with changing data, such as Open Graph cards, certificates, or product banners, and when a designer needs to edit the layout without a code deploy.

    Can a template API screenshot a URL?

    No. jsontoimg renders designs you build in its editor and fills their named layers. For capturing an existing web page, use a screenshot or HTML to image service.

    Is Satori or Next.js ImageResponse an HTML to image API?

    It converts JSX and a CSS subset to PNG inside your own app. It is lighter than a headless browser, but flexbox only, with a 500KB bundle cap, and the layout still lives in code.

    Related Resources

  • Image Generation API Buyer’s Guide: 8 Questions to Ask

    An image generation API takes structured data and returns a finished file, so the contract matters more than the demo. Eight questions separate the APIs that survive production from the ones that only look good in a landing-page GIF. For each one, this guide gives the jsontoimg answer, so you can hold any vendor to the same bar. jsontoimg fills named layers on a template you design; it is not a text-to-image model like Midjourney.

    1. What happens when a layer name is wrong?

    A loose API ignores the typo and ships the placeholder text to production. A strict one refuses the request. jsontoimg answers with a 422 on unknown layer keys (see 422 Unprocessable Content), and "dryRun": true validates a payload without creating a job or spending a credit. Test any vendor by sending headlne instead of headline.

    2. Can a design edit break jobs already in flight?

    Production should pin a template version. jsontoimg accepts version on the render call and bakes version=1 into every signed URL, so a designer saving a new layout never changes an image your site already references.

    3. What does one credit buy?

    Ask whether video seconds, animation, or AI credits share the pool. At jsontoimg one credit is one successful PNG, JPG, WebP, or AVIF render, or one PDF page. Failed jobs are free, and a quota overrun returns 402 Payment Required instead of a surprise overage bill. The full price table is in Image Generation API Pricing.

    4. How do I embed an image without leaking the API key?

    <img> and og:image cannot send an Authorization header. The answer is a signed URL: mint it with your key, then let browsers and crawlers fetch it anonymously. Minting is free; the first unique GET bills one credit. Change one query parameter and the signature fails with 401 Unauthorized.

    5. What does the first request of a slow render return?

    jsontoimg returns 503 with a Retry-After header while the first render finishes, which is the behaviour RFC 9110 defines for 503 and what crawlers retry on. An API that holds the connection open instead will time out inside a social-network scraper.

    6. How does it scale past one request?

    Look for batch endpoints, completion webhooks, and idempotency keys. jsontoimg queues 50 jobs per batch and sends render.completed and render.failed webhooks carrying an eventId you can dedupe on.

    7. Which output formats are real?

    PNG, JPG, WebP, AVIF, and PDF, with one set of layer overrides across all of them. transparent works with PNG, WebP, and AVIF and is rejected for PDF. If you are choosing between raster formats, MDN's image file type guide lists the trade-offs.

    8. Can a non-engineer change the layout?

    The designer owns the canvas in the editor. The engineer owns the payload. If changing a font size requires a pull request, you bought a rendering library, not a template API. The same question drives HTML to image API vs template API.

    Where jsontoimg is the wrong answer

    You need MP4 output, social publishing, or an embeddable editor inside your own product. See the alternatives for tools built around those jobs.

    FAQ

    What is an image generation API?

    A web service that accepts structured data and returns a rendered image or PDF. Template-driven ones such as jsontoimg fill named layers on a design you drew in an editor, so every response keeps the same layout.

    Is an image generation API the same as an AI image generator?

    No. An AI image generator invents pixels from a text prompt. A template-driven image generation API places your text, photos, and codes into a fixed layout, so the output is predictable and on-brand.

    How do I test an image generation API before paying?

    Send a deliberately wrong layer name, request the same payload twice, and fetch a signed URL with one parameter changed. jsontoimg gives every account 25 free API images with no card, enough to run all three checks.

    How much does jsontoimg cost?

    25 lifetime API images are free. Prepaid packs start at $5 for 250 images and never expire. Monthly plans start at $29 for 1,000 images.

    Related Resources

  • Puppeteer Alternative: Why I Built a JSON-to-Image API

    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 — not a product brochure.

    Overview

    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 — 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.

    The Puppeteer Honeymoon Phase

    Let me be fair: Puppeteer *feels* like the obvious choice at first. npm install puppeteer downloads a bundled Chromium, and you’re generating images within the hour:

    const puppeteer = require('puppeteer');
    
    (async () => {
      const browser = await puppeteer.launch();
      const page = await browser.newPage();
      await page.setViewport({ width: 1200, height: 630 });
      await page.goto('https://example.com/og-template', { waitUntil: 'networkidle0' });
      await page.screenshot({ path: 'og-image.png' });
      await browser.close();
    })();
    

    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* — which is exactly when the “free browser” stops being free.

    Where the Browser Stops Being Cheap

    Here’s what nobody mentions in the Puppeteer tutorial: every browser instance you spawn is a full Chromium process. That has real, measurable consequences:

    • Memory: a single Chromium instance consumes roughly 80–300 MB of RAM depending on page complexity, and a render can pin a CPU core for 1–3 seconds (source: Medium architecture deep dive).
    • Memory leaks: Chromium leaks. A well-documented story from the SnapRender team — they spent four months fighting Puppeteer OOM crashes before switching to an API. Their browser containers died every 50 requests, failed 2–3% of screenshots, and required 3–4 workers with recycling just to stay alive (source: SnapRender).
    • Scaling ceilings: a single render server hits its limit at roughly 10–20 concurrent renders. Beyond that you need horizontal scaling: queues, worker pools, health checks, crash watchdogs, and retry logic — all of which you build yourself (source: Medium architecture deep dive, Urlbox on Kubernetes scaling).
    • Version drift: Chrome updates break your renders. Fonts render differently across environments. Cookie banners, network timeouts, and flaky networkidle0 waits make output nondeterministic.

    The cost isn’t the Chrome license — it’s the engineering time spent keeping the browser farm alive. SnapRender’s numbers are telling: their self-hosted setup cost $240/month in infra plus 10–15 engineering hours per month just to babysit it. A cost comparison from Pagebolt estimates real-world Puppeteer operations at $15,000–20,000/month when you include incident response and maintenance at 10M+ screenshots per month (source: Pagebolt).

    The Reframe: Screenshotting ≠ Rendering

    The turning point for me was realizing I had the wrong mental model. Puppeteer is a browser automation tool. It’s unbeatable when you need to click through pages, fill forms, extract data, or screenshot an *existing website*.

    But most “generate an image” 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 data-in, image-out — a rendering problem, not a browsing problem. You’re paying for a full JavaScript engine, layout engine, and network stack to draw text on a rectangle.

    The moment I separated those two mental models, the design for jsontoimg wrote itself.

    What jsontoimg Does Differently

    Instead of pointing a browser at HTML, jsontoimg is a JSON-driven renderer:

    1. Design a template — define the layout with placeholders for text, images, colors, and fonts.

    2. Send JSON data — one POST request with the values that change.

    3. Get an image back — a pixel-perfect PNG/JPG, rendered directly.

    POST /api/v1/render?wait=60
    {
      "template": "og-card",
      "format": "png",
      "layers": {
        "title": { "text": "Why I Built a JSON-to-Image API" },
        "author": { "text": "Balaji" },
        "date": { "text": "2026-07-31" }
      }
    }
    

    Because there’s no browser process, there are no memory leaks, no worker pools, no Chrome updates, and no 80–300 MB per render. A renderer is stateless and horizontally scales like any other API — batch an array of jobs, get an array of images back, or use webhooks for async delivery on large volumes. That’s the entire pitch: JSON in, image out, nothing to maintain.

    When You Should Still Use Puppeteer

    I don’t want this to read as “never use Puppeteer” — that would be dishonest. Keep the headless browser when:

    • You need to screenshot existing live web pages (visual regression testing, website previews, monitoring).
    • You need full browser interaction — login flows, form filling, multi-step automations before capture.
    • Image generation is a side feature and you have the infra team to own it.

    If your real job is turning data into branded images — OG cards, product banners, certificates, ad creatives, personalized email graphics — a browser is the expensive way to do a simple thing. Those are exactly the use cases we’ve built out as reference workflows, from product banners at 10K SKUs to certificate generation.

    Key Takeaways

    • Puppeteer is a browser automation tool, not an image rendering tool — using it for templated images means paying browser overhead for a rendering job.
    • The real cost of self-hosted rendering is engineering time: memory leak management, worker pools, scaling ceilings (~10–20 concurrent renders per server), and Chrome version drift.
    • Real-world numbers: SnapRender dropped from $240/mo + 10–15 eng hours to ~$99/mo after switching; Pagebolt estimates $15–20K/mo total at 10M+ screenshots.
    • A JSON-driven render API removes the browser entirely: stateless, deterministic, horizontally scalable, nothing to babysit.
    • Use Puppeteer for live-page screenshots and browser interactions; use a render API for templated, data-driven images.

    FAQ

    Is Puppeteer cheaper than an image generation API?

    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.

    What breaks first when you self-host headless Chrome?

    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.

    When should I still use Puppeteer?

    When the thing you need a picture of is a real web page — 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.

    What is the difference between screenshotting and rendering?

    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.

    Related Resources

    Zoom out: How JSON-to-Image Conversion Works maps the whole template, named-layer, and render-job architecture.

  • Image Generation API Tutorial: Your First Render Call

    This is the first successful POST /api/v1/render — not a second homepage. Create an API key, send a template id and optional layer overrides, wait up to 60 seconds, download the file. 25 images are free; no card.

    Overview

    Every product team needs generated images at some point: Open Graph cards for blog posts, product banners for thousands of SKUs, certificates, ad creatives for A/B tests, personalized email headers. You have three options — design them by hand in Figma or Canva (doesn’t scale past a few images), run a headless browser like Puppeteer (high maintenance and expensive), or use a purpose-built image generation API.

    jsontoimg is the third option, stripped to its core job: JSON in, image out. You design a template once, send JSON data, and get back a rendered PNG, JPG, WebP, AVIF, or PDF, at any volume.

    This tutorial gets you from zero to your first rendered image in about five minutes. By the end you’ll have:

    • A simple template defined in JSON
    • Your first API call with curl
    • Working examples in Node.js and Python
    • A batch job generating multiple images in one request

    No prior image-generation experience needed. If you know what a POST request is, you’re ready.

    What “JSON to Image” Actually Means

    The core idea is a three-part pipeline:

    Design a template (once)
      → Send JSON data (every time)
      → Get an image back (instantly)
    

    A template is a design with placeholders — dynamic text, images, and colors you control through the API. Your data is plain JSON that fills those placeholders. The render is the image that comes out.

    The power is in the separation: you design the visual once, then any system that can send JSON — a CMS, a database, a spreadsheet, a webhook — can produce branded images without touching a design tool. This is the same pattern every serious template-based image API uses: Bannerbear sends a modifications array against a template (Bannerbear API Quick Start), Placid sends layers against a template_uuid (Placid REST API docs), and Pixelixe describes it as “one JSON request, one rendered output, unlimited reuse” (Pixelixe JSON to Image API). jsontoimg follows the same convention, so if you’ve used any of them, the mental model transfers immediately.

    Before You Start

    You need two things:

    1. A jsontoimg account and API key — grab your key from the dashboard. It’s a bearer token; keep it server-side and never in client code.
    2. A way to make HTTP requests — curl works for testing. For real integrations, Node.js 18+ (native fetch) or Python 3 with requests are covered below.

    Step 1: Design Your First Template

    Templates are JSON documents that describe the canvas: dimensions, background, and layers. Here’s a minimal branded card — a 1200×630 social share image with a gradient background, a headline, and a subtitle:

    {
      "width": 1200,
      "height": 630,
      "background": {
        "type": "gradient",
        "colors": ["#1a1a2e", "#16213e", "#0f3460"]
      },
      "layers": [
        {
          "type": "text",
          "name": "headline",
          "text": "Your headline goes here",
          "font": { "size": 72, "weight": "bold", "color": "#ffffff" },
          "position": { "x": 80, "y": 200 },
          "width": 1040,
          "align": "left"
        },
        {
          "type": "text",
          "name": "subtitle",
          "text": "Your subtitle goes here",
          "font": { "size": 36, "color": "#a0aec0" },
          "position": { "x": 80, "y": 330 },
          "width": 1040,
          "align": "left"
        }
      ]
    }
    

    A few things to note:

    • name is the layer’s ID — you’ll reference it in every API call. Keep it stable: headline, subtitle, logo, price.
    • text is the default value. The API overrides it per request, but a sensible default makes the template testable in the editor.
    • Text styling — size, weight, color, alignment, and wrapping are all first-class properties. You can also add image layers (for logos and photos) and shape layers (for badges and dividers).

    Once saved, the template gets a template ID that you’ll use in all render calls.

    Step 2: Make Your First API Call

    With the template saved, generating an image is a single POST to the render endpoint:

    POST https://app.jsontoimg.com/api/v1/render
    

    Here’s the same request with curl:

    curl -X POST "https://app.jsontoimg.com/api/v1/render?wait=60" \
      -H "Authorization: Bearer $JSONTOIMG_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "template": "social-share-card",
        "format": "png",
        "layers": {
          "headline": { "text": "Launching the New Dashboard" },
          "subtitle": { "text": "Real-time analytics for your team" }
        }
      }'
    

    The response is small and predictable:

    {
      "id": "rnd_a1b2c3",
      "status": "done",
      "format": "png",
      "assetUrl": "https://app.jsontoimg.com/api/v1/renders/rnd_a1b2c3/asset?sig=..."
    }
    

    The image_url is the finished PNG, ready to host, serve, or upload anywhere. You’re done — that’s the whole first call.

    Node.js

    const JSONTOIMG_API_KEY = process.env.JSONTOIMG_API_KEY;
    
    async function renderImage() {
      const response = await fetch('https://app.jsontoimg.com/api/v1/render?wait=60', {
        method: 'POST',
        headers: {
          'Authorization': `Bearer ${JSONTOIMG_API_KEY}`,
          'Content-Type': 'application/json'
        },
        body: JSON.stringify({
          template: 'social-share-card',
          format: 'png',
          layers: {
            headline: { text: 'Launching the New Dashboard' },
            subtitle: { text: 'Real-time analytics for your team' }
          }
        })
      });
    
      const data = await response.json();
      console.log(data.assetUrl);
    }
    
    renderImage();
    

    Python

    import os
    import requests
    
    API_KEY = os.environ['JSONTOIMG_API_KEY']
    
    response = requests.post(
        'https://app.jsontoimg.com/api/v1/render',
        headers={
            'Authorization': f'Bearer {API_KEY}',
            'Content-Type': 'application/json'
        },
        json={
            'template': 'social-share-card',
            'format': 'png',
            'layers': {
                'headline': { 'text': 'Launching the New Dashboard' },
                'subtitle': { 'text': 'Real-time analytics for your team' }
            }
        }
    )
    
    print(response.json()['assetUrl'])
    

    Step 3: Sync vs Async vs Webhooks

    Rendering a single image is fast — usually a second or two — so the synchronous call above is all you need for most cases. But at volume you’ll want the async patterns that production integrations use. Here’s how the three modes compare:

    Mode How it works Best for
    Synchronous Connection stays open; image_url returned in the response Simple renders, low volume, Lambda/edge functions
    Async + polling Response returns job_id and status: "queued"; you poll a status endpoint Large or complex renders where you don’t want to hold the connection
    Webhook Pass webhook_url; jsontoimg POSTs the finished image to your endpoint High-volume batch pipelines, event-driven systems

    For polling, the response looks like this:

    {
      "status": "queued",
      "job_id": "job_8f3k2m"
    }
    

    Then you poll until the job completes:

    curl -X GET "https://app.jsontoimg.com/api/v1/renders/rnd_8f3k2m" \
      -H "Authorization: Bearer $JSONTOIMG_API_KEY"
    

    A common production pattern is exponential backoff — poll at 1s, 2s, 4s, 8s — rather than hammering the endpoint every second (Wireflow’s developer guide covers exactly this trade-off). And for anything beyond a few seconds of processing, webhooks are the standard recommendation: your server gets notified when the job completes instead of polling at all (Apiframe’s 2026 API roundup). Bannerbear and Placid offer the same dual pattern — poll a GET endpoint or receive a webhook POST (Bannerbear help, Placid docs).

    Step 4: Generate Your First Batch

    Single renders are nice; batches are where the API earns its keep. Send an array of renders in one request:

    const response = await fetch('https://app.jsontoimg.com/api/v1/renders/batch', {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${JSONTOIMG_API_KEY}`,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        jobs: [
          {
            template: 'social-share-card',
            format: 'png',
            layers: {
              headline: { text: 'Post 1: The Ultimate Guide' },
              subtitle: { text: 'Everything you need to know' }
            }
          },
          {
            template: 'social-share-card',
            format: 'png',
            layers: {
              headline: { text: 'Post 2: Case Study' },
              subtitle: { text: 'How one team scaled to 10K images' }
            }
          }
        ]
      })
    });
    
    const results = await response.json();
    // GET /api/v1/renders/batches/{id}; each done job has assetUrl
    

    One template, hundreds of variations, one request. This is the workflow behind the big use cases on the site:

    If you’re evaluating whether template-based rendering is the right pattern for your stack at all, the Abyssale comparison of template-based image APIs is a good industry overview — and the jsontoimg vs Bannerbear and jsontoimg vs Placid pages cover where the trade-offs land.

    Common Mistakes and How to Fix Them

    Error / symptom Likely cause Fix
    401 Unauthorized Wrong or missing API key Confirm Authorization: Bearer ; never hardcode keys in client code
    404 template not found Typo in template Copy the ID from the dashboard exactly
    Render succeeds but text is unchanged name doesn’t match a layer The modification name must equal a layer name in the template
    Text clipped or overflowing Font too large for the layer width Check font.size against the layer width and align settings
    Slow responses on big batches Many heavy renders in one call Use the batch endpoint with a webhook_url and process asynchronously
    Rate limit errors Too many requests per second Add backoff; the async/webhook path is more forgiving at volume

    Next Steps

    You’ve made your first call. The natural next step is to wire this into a real workflow:

    1. Read the use case guides — OG images, email hero images, event tickets show the full pipelines.
    2. Build something — the product banner generator walkthrough takes the batch pattern above and points it at a real product catalog.
    3. Compare options — if you’re still deciding between providers, the comparison series covers the honest trade-offs.

    And if you’re curious about the technical story behind why a JSON-driven API beats a headless browser, check out Why I Built a JSON-to-Image API Instead of Using Puppeteer (coming soon) — spoiler: it’s the cost and the ops burden.

    Key Takeaways

    • JSON in, image out — a template + a JSON payload is all you need to generate branded images at scale
    • Design once, render forever — templates separate the visual design from the data, so any system that speaks JSON becomes an image generator
    • The API is one POST — template + layers → assetUrl; the same convention as Bannerbear, Placid, and Pixelixe
    • Pick the right mode — synchronous for simple renders, polling for long jobs, webhooks for production pipelines
    • Batch is where scale happens — one request, hundreds of images
    • First render in ~5 minutes — template → curl → done

    FAQ

    What do I need before my first render?

    An account, an API key, and one template with its changing layers named. Every account starts with 25 free API images and no card, so you can get through a first call before deciding anything.

    What does the minimal JSON to image request look like?

    A POST /api/v1/render with the template ID and an object of layer names to values. Layers you do not mention keep the defaults you set in the editor.

    Why is my render returning 422?

    Almost always a layer name that does not exist in the template — a typo or a layer renamed in the editor. The API rejects unknown keys instead of quietly rendering an image with a missing field.

    When should I move from single renders to the batch endpoint?

    As soon as you are rendering a list rather than one image. POST /api/v1/renders/batch takes up to 50 jobs per request and can report back by webhook.

    Do failed calls use up my free images?

    No. Credits are spent on successful renders only, and designing in the editor with watermarked previews does not touch them at all.

    Related Resources

    Next: docs, named layers, pricing.

    Zoom out: How JSON-to-Image Conversion Works maps the whole template, named-layer, and render-job architecture.