Ad creatives from a spreadsheet or product feed
Performance campaigns need the same ad in many variants: one per product, price, audience or language, and each in several sizes. This guide builds that once and generates the variants from your data, three ways: a zip from a spreadsheet, a script that renders from your feed, and image URLs you put straight into an ad platform’s catalog feed.
How it works
- One template, several sizes. A template is a React component styled with Tailwind. The render API can set the size per request, so a feed ad (1200 × 628), a square (1080 × 1080) and a story (1080 × 1920) can come from one template with a flexible layout. When a size needs a different layout, give it its own template with the same props.
- Props are the columns of your data: product name, headline, price, old price, image URL, call to action.
- Each row becomes an image in every size you need.
Step 1: build the templates
Start from the Display ad example in the playground
(Templates, then Display ad), or describe the ad to your AI assistant
through the MCP server. Put everything that
changes per ad in export const props:
export const props = {
product: "Trail Runner 2",
headline: "Built for mud. Light on the road.",
price: "$89",
oldPrice: "$119",
cta: "Shop now",
photo: "https://example.com/products/trail-runner-2.jpg",
};
type Props = typeof props;
export default function FeedAd(props: Props) {
return (
<div class="flex h-full w-full bg-white">
<img src={props.photo} class="h-full w-1/2 object-cover" />
<div class="flex w-1/2 flex-col justify-center gap-6 p-14">
<span class="text-2xl font-semibold uppercase tracking-widest text-orange-600">
{props.product}
</span>
<h1 class="m-0 text-6xl font-bold leading-tight text-slate-900">
{props.headline}
</h1>
<div class="flex items-baseline gap-4">
<span class="text-5xl font-bold text-slate-900">{props.price}</span>
<span class="text-3xl text-slate-400 line-through">{props.oldPrice}</span>
</div>
<div class="flex w-fit rounded-full bg-orange-600 px-8 py-4 text-2xl font-semibold text-white">
{props.cta}
</div>
</div>
</div>
);
}
export const options = { width: 1200, height: 628, format: "jpeg", quality: 85 };
Save it. With the render API you can then ask for other sizes from this
template, see the script below. When
a size needs a different arrangement, a story stacking the photo above the text
for example, make it with Templates ▾ → Duplicate template: change width
and height, rearrange the layout, and keep the same props. Bulk export uses
each template’s own size, so it needs one template per size.
A few things that matter for ads:
- Long text. Test the longest product name and headline you have. Clamp or
shorten in the template if needed, for example
props.headline.slice(0, 60). - Prices are text. Format them in your data (
$89,89 kr) and they render as written. - Product photos are fetched from their URLs when the image renders. Keep them under 10 MB each.
- JPEG at quality 80–90 keeps ad images small. Use PNG when you need sharp flat graphics or transparency.
Step 2: generate the ads
A campaign from a spreadsheet: bulk export
For a one-off campaign, no code at all:
- Put your ads in a spreadsheet, one row per ad, with a header row:
product,headline,price,oldPrice,cta,photo
Trail Runner 2,Built for mud. Light on the road.,$89,$119,Shop now,https://example.com/p/tr2.jpg
Ridge Pro,Grip for every season.,$129,$159,Shop now,https://example.com/p/ridge.jpg
- Open a template in the playground and click Bulk. Choose the
.csvor.xlsxfile. Columns become props by their header; you can rename or skip columns. - Name the files after a column (for example
product), pick the format and click Render. The ads download as one zip. - Repeat with each size’s template.
Bulk export runs in your browser: nothing is uploaded, and it doesn’t use your monthly renders. The number of rows per run depends on your plan, see pricing.
Automated from your feed: the render API
When ads should follow your product data every day, render them from a script or a job. This Node.js script (18 or later) renders every product in every size and saves the files:
import { mkdir, writeFile } from "node:fs/promises";
const API_KEY = "YOUR_API_KEY"; // from the API keys page; keep it on the server
const TEMPLATE = "<template-uid>";
const SIZES = {
feed: { width: 1200, height: 628 },
square: { width: 1080, height: 1080 },
story: { width: 1080, height: 1920 },
};
const products = await (await fetch("https://example.com/products.json")).json();
await mkdir("ads", { recursive: true });
for (const product of products) {
for (const [size, { width, height }] of Object.entries(SIZES)) {
const res = await fetch("https://jsximage.com/api/render", {
method: "POST",
headers: {
Authorization: `Bearer ${API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
template: TEMPLATE,
options: { width, height },
props: {
product: product.name,
headline: product.tagline,
price: product.price,
oldPrice: product.oldPrice,
cta: "Shop now",
photo: product.imageUrl,
},
}),
});
if (!res.ok) throw new Error(`${product.id} ${size}: ${(await res.json()).error}`);
await writeFile(
`ads/${product.id}-${size}.jpg`,
Buffer.from(await res.arrayBuffer()),
);
}
}
The side-by-side example above suits wide and square sizes; a story usually
needs its own layout. Give that size its own template and send its uid instead.
Each successful call uses one render. When the monthly quota is used up, the API
returns 429 with a Retry-After header. Every response has the remaining quota
in X-Quota-Remaining. Details: the render API.
Straight into a catalog feed: live image URLs
Ad platforms that build ads from a product catalog, such as Google Merchant Center and Meta catalogs, read each product’s image from a URL in the feed. Point that URL at JSXImage and the platform fetches a finished ad image:
- Sign one URL per product with its props, in the code that builds your feed. The template’s Sign URLs in your code tab (next to Create URL) gives a ready-made function, and Open Graph images shows it step by step.
- Put the URL in the feed’s image column.
Each URL uses one render the first time it is fetched; fetching it again is free. If you change the design and save, every product’s image shows the new design. A price change is a new URL, so it renders once more.
Good to know
- Test a few rows first. Run two or three rows through bulk export before a full campaign.
- Brand fonts. Add them with
googleFontor a font URL in the template’s options, see Fonts. - Languages. Put the translated text in the data; one template serves every language. Scripts like Arabic or Japanese need a font that covers them, see Emoji and other scripts.
Questions? See the docs or email info@jsximage.com.