JSONtoIMG

Blog

  • Ecommerce Product Banner Generator Script (Batches of 50)

    A catalog script: read rows, map columns to named layers, POST batches of 50, retry failures. Product story: /use-cases/product-banners.

    Overview

    If you run an online store with more than a few dozen products, you know the pain: every product needs a banner for the category page, a variant for the sale, a version for the newsletter, and yet another crop for social ads. Multiply that by hundreds or thousands of SKUs and manual design stops being an option — it becomes the bottleneck that quietly caps your marketing velocity.

    This post walks through building a product banner generator for e-commerce using jsontoimg: a JSON-in, image-out API. You design one template, connect your product catalog, and generate on-brand banners for every SKU automatically — including sale badges, dynamic pricing, and seasonal variants. By the end, you’ll have a pipeline that turns a product record into a finished banner in under a second.

    Why Manual Banner Design Doesn’t Scale

    A typical store with 500 SKUs and four seasonal promotions per year needs roughly 2,000+ banner variations annually — before you count A/B test variants or per-platform crops. The three common approaches all break at that volume:

    • Design tools (Figma/Canva) — a designer spends 15–30 minutes per banner; 2,000 banners is 500–1,000 hours of work a year. It’s also error-prone: prices change, badges go stale, and files drift out of sync with the catalog.
    • Headless browsers (Puppeteer/Playwright) — you get full control, but you’re now running rendering infrastructure: servers, memory limits, font loading, and constant maintenance. For a store that just wants banners, it’s a second product to operate.
    • Static templates in the frontend (HTML/CSS + screenshots) — brittle, hard to keep pixel-perfect across browsers, and every layout change means re-engineering.

    The alternative is a template-based image API: define the design once, send JSON per product, get an image back. No designers burned on repetitive work, no rendering infrastructure to run.

    The Architecture: Catalog → JSON → Banner

    The whole system has four moving parts:

    Product catalog (Shopify / WooCommerce / your DB)
            │  product data: name, price, image, badge, category
            ▼
    JSON payload → jsontoimg API
            │  renders template with your data
            ▼
    Banner image (PNG/JPG)
            │  stored on S3 / R2 / your CDN
            ▼
    Served on category pages, emails, ads, social
    

    The beauty is that the catalog is already structured data. A product *is* a JSON object: name, price, compare-at price, image URL, badge text. That’s exactly what a template-based API consumes.

    Step 1: Design Your Product Banner Template

    First, design a template in jsontoimg with placeholders for everything that changes per product. A standard product banner is 1200×628 (works for category headers, ads, and social). Your template should include:

    • Background — brand color or gradient, optionally a subtle seasonal treatment
    • Product image — the hero visual, with a placeholder for the image URL
    • Product name — bold headline text
    • Price / compare-at price — dynamic pricing with currency
    • Sale badge — a “30% OFF” or “NEW” pill that appears conditionally
    • Category or store logo — for branding consistency

    In jsontoimg the template is defined as structured JSON with dynamic placeholders. Conceptually it looks like this:

    {
      "width": 1200,
      "height": 628,
      "background": { "type": "solid", "color": "#f7f7f8" },
      "layers": [
        {
          "type": "image",
          "source": "named layer product_image",
          "x": 80, "y": 80, "width": 480, "height": 480
        },
        {
          "type": "text",
          "text": "named layer product_name",
          "x": 620, "y": 140, "size": 44, "weight": "bold", "color": "#111827",
          "max_width": 480, "wrap": true
        },
        {
          "type": "text",
          "text": "named layer price",
          "x": 620, "y": 320, "size": 52, "weight": "bold", "color": "#0f766e"
        },
        {
          "type": "text",
          "text": "named layer compare_at_price",
          "x": 620, "y": 390, "size": 28, "color": "#9ca3af",
          "strikethrough": true
        },
        {
          "type": "badge",
          "text": "named layer badge",
          "visible": "named layer has_badge",
          "x": 620, "y": 80, "background": "#dc2626", "color": "#ffffff"
        }
      ]
    }
    

    Notice the design decisions baked in: text has a max_width with wrapping so long product names never overflow, the badge is conditional via visible, and the price uses a larger, brand-colored style so the discount pops. Design once, reuse for every SKU.

    Step 2: Generate Banners for Your Catalog

    Once the template exists, generating banners is a single API call per product. Here’s a minimal Node.js example that pulls products from any source and renders a banner for each:

    const products = await fetchCatalog(); // Shopify, WooCommerce, your DB
    
    const banner = await fetch("https://app.jsontoimg.com/api/v1/render?wait=60", {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "Authorization": "Bearer $JSONTOIMG_API_KEY",
      },
      body: JSON.stringify({
        template: "product-banner-v1",
        format: "png",
        layers: {
          product_image: { src: products[0].image_url },
          product_name: { text: products[0].title },
          price: { text: `$${products[0].price}` },
          badge: { text: products[0].on_sale ? "SALE" : "" },
        },
      }),
    });
    
    const result = await banner.json();
    // result.assetUrl → GET /api/v1/renders/{id}/asset
    

    For hundreds of SKUs, send them as a batch — jsontoimg accepts an array and returns an array, so one request covers many products:

    {
      "jobs": [
        {
          "template": "product-banner-v1",
          "format": "png",
          "layers": {
            "product_name": { "text": "Wireless Headphones" },
            "price": { "text": "$79.99" },
            "badge": { "text": "30% OFF" }
          }
        },
        {
          "template": "product-banner-v1",
          "format": "png",
          "layers": {
            "product_name": { "text": "Mechanical Keyboard" },
            "price": { "text": "$129.00" }
          }
        }
      ]
    }
    

    Step 3: Automate the Triggers

    A banner generator is only valuable if it runs without you. Wire the render call into the events your store already emits:

    • Product created/updated (webhook) — Shopify and WooCommerce both fire webhooks on product changes. Listen for products/create and products/update, render the banner, and store the URL back on the product record.
    • Scheduled jobs (cron) — re-render sale banners nightly so prices and badges never go stale.
    • Workflow tools (n8n / Zapier / Make) — trigger a render when a spreadsheet row is added; handy for seasonal campaigns where the promo list lives outside your store.
    • CI/CD for marketing — on every deploy of a campaign, regenerate the full set of ad creatives.

    Here’s a minimal webhook handler for a store product update:

    app.post("/webhooks/products/update", async (req, res) => {
      const product = req.body;
      const image = await renderBanner(product); // Step 2 logic
      await saveBannerUrl(product.id, image.image_url); // back to catalog or CDN
      res.sendStatus(200);
    });
    

    Step 4: Store and Serve

    Save generated banners to object storage (S3, Cloudflare R2, or any CDN) and reference the URL — don’t store blobs in your database. A few serving tips:

    • Cache aggressively — banners change when prices change, not per page view. Cache with a short TTL (e.g., 15–60 minutes) so a sale update propagates without hammering the API.
    • Version by template — include the template version in the filename (banner-v1-{sku}.png) so a template redesign doesn’t invalidate old URLs mid-campaign.
    • Generate on demand, cache forever — compute the banner URL from the SKU + template version; render only when the image doesn’t exist yet. This gives you instant banners for 10K SKUs with a tiny render footprint.

    If the banners feed a shopping surface rather than only your own storefront, the specs are not yours to choose. Google Merchant Center's image requirements set minimum dimensions and prohibit promotional overlays on the main product image, which is a constraint worth encoding in the template rather than discovering at review time. For the trigger side, Shopify's webhook topics are the canonical list of the events worth re-rendering on — a product update or an inventory change, rather than a nightly full sweep. On delivery, web.dev's format guidance favours WebP or AVIF for storefront imagery, and Google's image SEO documentation covers the filename and alt-text habits that make generated banners findable.

    Best Practices for Product Banners

    • Watch platform image specs — Amazon recommends at least 1,000 px on the longest side for zoom (500 px minimum), while Google Shopping moves to a 500×500 px minimum in January 2027. Design templates at a base size that comfortably exceeds marketplace minimums and export downscaled variants.
    • Test with real variable content — render a few banners with the longest product names in your catalog, non-Latin characters, and missing images. The templates that break are the ones you didn’t test.
    • Handle missing images gracefully — products without photos happen. Give the template a placeholder fallback so a banner renders instead of erroring.
    • Keep badges conditional — a badge layer with visible: false costs nothing when the product isn’t on sale, and keeps the design clean.
    • Log failures and retry — batch renders should tolerate partial failures: log the failed SKUs, retry once, and alert if the same SKU fails twice.

    Beyond Banners: The Same Pipeline, Every Asset

    Once the banner pipeline exists, the same catalog JSON powers every other visual: email hero images, social posts, ad variants for A/B tests, and certificate-style assets. You’re not building one automation — you’re building the rendering layer for your entire store’s visual content. (For the full catalog of scenarios, see the Product Banners use case page.)

    Key Takeaways

    • Manual design and headless browsers both break at e-commerce scale — a template-based image API is purpose-built for this job.
    • A product record is already JSON; that’s the exact input a template-based API needs.
    • Design one template with wrapped text, conditional badges, and dynamic pricing; then generate for every SKU in batch.
    • Automate triggers via store webhooks, cron, or n8n so banners stay fresh without human intervention.
    • Cache aggressively, version your templates, and test with real catalog data before launch.

    FAQ

    How do I keep product banners in sync with the catalog?

    Trigger a render from the event that changed the data — a price update, a stock change, a new SKU — rather than regenerating the whole catalog on a schedule. Only the rows that changed cost credits.

    Can I render banners for a whole catalog in one run?

    Yes, in chunks of 50 jobs per batch request. A 2,000-product catalog is 40 sequential batch calls, which is a script you can leave running.

    Where should the generated banners live?

    Store the rendered file and reference it by URL from your storefront. Re-rendering an unchanged product on every page view wastes credits for a file that never changed.

    What does a catalog-wide refresh cost?

    One credit per banner. Two thousand products is 2,000 images, so a full refresh fits inside a Pro month and an incremental daily sync costs a handful of credits.

    Related Resources

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

  • JSON to Image Converter: How the Conversion Works

    JSON-to-image conversion turns structured data into a finished image file by sending that data to a template whose changing parts are named layers. You design the layout once, name the slots that vary, then POST JSON that fills those slots. The renderer composites the result and returns a PNG, JPG, WebP, AVIF, or PDF. No browser, no screenshot, no design tool in the request path.

    That is the entire architecture. This page is the map to it: what each part does, which guide covers it in depth, and what people actually build once design stops being a manual step. If you only want to render something today, start with your first API call.

    The Three Parts of Every Conversion

    Every JSON to image request, on any platform worth using, decomposes into the same three pieces. Confusing them is the source of most of the pain people hit.

    Part What it is Who owns it
    Template The layout, fonts, colours, and fixed artwork — the parts that do not change per image A designer, once, in the editor
    Named layers The slots that do change: a headline, a price, a photo, a QR code Shared — the designer names them, your code fills them
    Job One request: this template, these layer values, this format and size Your application

    The split matters because it decides who is blocked on whom. When the template holds the design and your code only supplies values, marketing can restyle a banner without a deploy, and you can ship a new data source without opening a design tool. Both sides move independently because the layer names are the only thing they share.

    Why Not Just Screenshot a Browser?

    The obvious first instinct is to build the image as an HTML page and screenshot it with headless Chrome. It works on the first day and gets expensive after that. Each render holds a full browser process, so memory, not CPU, caps your concurrency. Fonts missing from the container do not raise an error — they silently substitute and change the output. Cold starts add seconds to a request that should take milliseconds.

    The deeper issue is that a screenshot reproduces whatever the browser happened to paint, including layout drift from a CSS change you did not intend. Compositing named layers is deterministic: the same JSON produces the same pixels. We wrote up both sides of this — why we chose not to run Puppeteer, including the cases where a browser genuinely is the right tool, and the rendering stack that replaced it.

    The Template Is the API Contract

    Once code sends values by layer name, those names are a public interface. Renaming product_title breaks every caller, exactly like renaming a JSON field in a REST response. Treating templates as contracts rather than as documents is the single habit that keeps an image pipeline stable.

    Two mechanics make that practical. Unknown layer keys are rejected with a 422 rather than quietly dropped, so a typo fails loudly instead of shipping an image with a blank headline. And templates are versioned: a request can pin design_version, so your integration keeps rendering the version it was built against while a designer edits the draft. The full treatment — layer types, defaults, auto-fit, and overflow — is in designing image templates with JSON.

    Making the First Call

    A minimal conversion is a POST /api/v1/render carrying a template ID and an object of layer names to values. Layers you do not mention keep the defaults set in the editor, so a request only has to describe what differs from the design. The response gives you the rendered file.

    Every account starts with 25 free API images and no card, and designing in the editor with watermarked previews does not consume them, so you can get through a first render before deciding anything. The walkthrough with Node and Python examples is in getting started with jsontoimg.

    One Image or Fifty Thousand

    The interesting version of this problem is never one image. It is a catalogue, a cohort, or a campaign. POST /api/v1/renders/batch accepts up to 50 jobs per request, so volume is a loop of 50-job chunks rather than one enormous array — a 5,000-image run is 100 sequential requests. Pacing those chunks, rather than firing them all at once, is what keeps a bulk run stable.

    Billing follows the same simple rule at every scale: one credit is one successful still or one PDF page, and failed jobs are not charged. That makes the cost of a run arithmetic you can do before you write it. Three guides cover the shapes this takes in practice:

    How the Image Reaches Your Users

    Rendering is half the job; delivery is the other half, and there are three patterns. The synchronous path renders and returns the file inside your request, which is what an interactive flow needs. A signed URL, minted with POST /api/v1/img/sign, can be dropped straight into an img tag or a meta tag — the first unique GET renders and costs a credit, and every later request streams the stored file from a CDN. A webhook suits long batches, reporting each result as it lands instead of holding a connection open.

    The signed-URL pattern is what makes automated Open Graph images cheap: a viral page costs no more than a quiet one, because only the first view renders. The Open Graph protocol specification defines the og:image tags themselves, and in Next.js the URL is returned from generateMetadata like any other value. For WordPress, the plugin renders from the post's own fields on publish, using the WordPress REST API under the hood. Both wiring paths are in signing Open Graph image URLs, and the production shape of it in Open Graph image generation.

    Picking an Output Format

    The format argument is not cosmetic. WebP and AVIF are substantially smaller than JPG at matched quality, which is why web.dev's format guidance recommends them for anything served to a browser. The catch is support outside the browser: email clients remain uneven, so a hero image in a message should still be JPG. MDN's image file type guide is the reference for what each format can actually do.

    PDF is the odd one out and the most useful. A multi-page template renders to a multi-page PDF billed one credit per page, which is what makes certificates, tickets, and one-page reports a rendering problem rather than a document-engine problem.

    What People Convert JSON Into

    The pattern generalises further than most people expect, because almost every recurring image in a product is a template with a few values swapped. Nine of the common ones:

    • Open Graph images — a share card per page, generated from the page's own metadata
    • Social posts — on-brand graphics without a round trip through a design tool
    • Ad creatives — every cell of a headline x offer x background matrix
    • Certificates — one per recipient, as PNG or multi-page PDF
    • Product banners — rendered from catalogue rows and refreshed when price or stock changes
    • Event tickets — unique IDs and scannable codes per attendee
    • Welcome graphics — personalised onboarding images triggered on signup
    • Report thumbnails — a visual summary of numbers that change every period
    • Email hero images — one per subscriber, rendered at send time

    Two of these have their own deep dives worth reading before you build: personalised email hero images covers the 600-pixel width and client-safety constraints email imposes, and A/B testing ad creatives covers enumerating a test matrix and naming files so the results stay analysable. If images are part of how pages get discovered, Google's image SEO documentation is worth a pass on filenames and alt text.

    When a Different Tool Is the Right Answer

    The honest boundary: jsontoimg renders stills and PDF. It does not render MP4, GIF, or animation, and it is not a document engine for CSS-heavy HTML invoices. If one vendor has to cover image, video, and PDF creative, or if a native no-code connector is a hard requirement, another platform is the better fit. We wrote the comparisons rather than pretending the question does not come up:

    What we learned building in that market, including why a narrow wedge beat a broader platform, is in seven lessons from launching a stills-and-PDF image API.

    Go Deeper by Topic

    Four topic guides each own one part of the pipeline:

    Evaluating the field? Start with Image Generation API: 8 Questions to Ask Before You Pick One and HTML to Image API vs Template API.

    More patterns: YouTube thumbnails, Pinterest pins, testimonial images, name badges, coupons, and real estate listing images.

    FAQ

    What is a JSON-to-image converter?

    A service that renders structured data into an image file through a template. You send JSON naming the template's changing layers, and it returns a PNG, JPG, WebP, AVIF, or PDF. It is not a JSON pretty-printer that screenshots code — the output is a designed asset, not a picture of text.

    How is this different from an online JSON formatter?

    A formatter makes JSON readable to a human. A JSON to image API uses the JSON as input data for a design you control, so the same payload that holds a product name and price becomes a finished banner rather than a syntax-highlighted code block.

    Do I need to know design to use it?

    You need a template to exist. Someone draws it once in the editor and names the layers that change; after that, using it is a JSON request. Most teams have a designer build the template and engineers never open the editor again.

    What does automated image generation cost?

    One credit per successful still or PDF page, with failed renders not charged. Twenty-five images are free with no card, Starter is $29/mo for 1,000, and prepaid packs start at $5 and never expire. Current numbers are on the pricing page.

    Can I convert JSON to an image without writing code?

    Partly. There is an n8n community node, a WordPress plugin, an MCP server for AI agents, and a CLI. Zapier, Make, Google Sheets, and Airtable connect through a plain HTTP request until native connectors ship, so a no-code tool that can call a webhook can drive it.

    Related Resources

  • Hello world!

    Welcome to Skndan CMS Sites. This is your first post. Edit or delete it, then start writing!