# How to generate images from a Google Sheet or an Airtable table

Source: https://snapsbrew.com/guides/generate-images-from-spreadsheet

Name the columns of your sheet after the layer keys of a Snapsbrew template, then export the sheet as CSV. Upload the CSV on the template page, and Snapsbrew renders one image or PDF for each row. For a repeat job, a script reads the CSV, sends batches of 100 rows to the API, and writes the image URLs back.

By [Alejandro Medina](https://amedina.me), maintainer of Snapsbrew. Published 27 November 2026. Last updated 27 November 2026.

On this page

- [Before you start](#before-you-start)
- [Part 1: Upload a CSV, no code](#part-1-upload-a-csv-no-code)
- [Part 2: A script for a repeat job](#part-2-a-script-for-a-repeat-job)
- [Images or PDFs for print](#images-or-pdfs-for-print)

Most bulk image jobs start in a spreadsheet. A list of event speakers, a product feed, the names on 300 course certificates, a table of real estate listings. Someone keeps the list in Google Sheets or Airtable, and someone else makes the images by hand in a design tool, one at a time.

This guide connects the two. Each row of the sheet becomes one image or one PDF, rendered from one Snapsbrew template. Part 1 needs no code. Part 2 is a script for a job that runs every week.

## Before you start

You need a Snapsbrew instance and a published template. Each part of the design that changes from row to row is a layer with a key, for example `name`, `role`, `photo` and `accent`. Read [Layers and variants](https://snapsbrew.com/docs/using-snapsbrew/layers-and-variants.md).

Then make the header row of your sheet match the layer keys exactly. A sheet for speaker cards looks like this:

| name       | role                  | photo                         | accent  |
| ---------- | --------------------- | ----------------------------- | ------- |
| Ada Okafor | Staff engineer, Lumen | <https://example.com/ada.jpg> | #ff5a36 |
| Rui Tanaka | CTO, Fieldnote        | <https://example.com/rui.jpg> |         |

The empty `accent` cell keeps the color of the template.

## Part 1: Upload a CSV, no code

### Get the exact columns

1. Open the template on your instance.
2. In the **Imports** panel, click **Start an import**.
3. Click **Download Excel template**.

The file has one column for each layer key in row 1, and the current value of each layer in row 2. Copy row 1 into your sheet, or paste your data under it.

### Export the sheet

- **Google Sheets:** open the tab, then click **File > Download > Comma-separated values (.csv)**. A CSV file holds one tab only. Read the [Google help page about downloads](https://support.google.com/docs/answer/49114).
- **Airtable:** open the view, click the arrow next to the view name, then click **Download CSV**. The filters of the view limit the rows of the file. Hide the fields that are not layer keys first. Read the [Airtable help page about views](https://support.airtable.com/articles/5189551686-getting-started-with-airtable-views).

### Import

1. On the **New Snaps Import** page of the template, type a title.
2. If another system needs to know when the import ends, type a webhook URL.
3. Upload the file.

The instance queues one snap for each row and shows the progress. The rules for the file are strict on purpose:

- A column that is not a layer key stops the import, with an error that names the column.
- A layer key with no column also stops the import.
- The maximum file size is 10 MB.

### Which cell changes what

The instance picks the change from the type of the layer:

| The layer has      | The cell becomes           |
| ------------------ | -------------------------- |
| Text               | The new text               |
| A QR code          | The content of the QR code |
| A barcode          | The value of the barcode   |
| A background image | The image URL              |
| A background color | The color                  |

An image cell must hold a public `http` or `https` URL. A file name such as `ada.jpg` does not work. If your photos are attachments in Airtable or files in Google Drive, put them at a public URL first, for example in a storage bucket.

## Part 2: A script for a repeat job

The upload is fine for one list. For a list that changes every week, a script saves the export and the upload. It reads the sheet as CSV, sends the rows to the batch API, waits, and writes the image URL of each row to a file.

### Get a CSV URL of the sheet

In Google Sheets, **File > Share > Publish to web** publishes one tab at a fixed URL, and you can choose the format of the file. Choose CSV. Everyone with the URL can read the tab, so use it only for data that is not private. Read the [Google help page about publishing](https://support.google.com/docs/answer/183965). For private data, download the CSV with the Google Sheets API or the Airtable API and a key, and pass the file to the script.

### The script

Install the JavaScript SDK and a CSV parser:

```bash
npm install github:amedina068/snapsbrew-js csv-parse

```

```js
// sheet-to-images.mjs
import { writeFileSync } from 'node:fs'
import { parse } from 'csv-parse/sync'
import { Snapsbrew } from 'snapsbrew'

const sb = new Snapsbrew({ baseUrl: process.env.SNAPSBREW_URL, token: process.env.SNAPSBREW_TOKEN })
const templateId = process.env.TEMPLATE_ID

// Which variant property each column sets. Columns that are not here are not sent.
const columns = { name: 'text', role: 'text', photo: 'image_url', accent: 'background_color' }

const csv = await (await fetch(process.env.SHEET_CSV_URL)).text()
const rows = parse(csv, { columns: true, skip_empty_lines: true })

const lines = ['row,status,media_url']
for (let start = 0; start < rows.length; start += 100) {
  const chunk = rows.slice(start, start + 100)
  const batch = await sb.batches.create({
    templateId,
    title: `Sheet import, rows ${start + 2} to ${start + chunk.length + 1}`,
    items: chunk.map((row, i) => ({
      identifier: `row-${start + i + 2}`,
      variants: Object.entries(columns)
        .filter(([key]) => row[key])
        .map(([key, property]) => ({ layer: key, [property]: row[key] })),
    })),
  })

  const done = await sb.batches.wait(batch.uuid, { signal: AbortSignal.timeout(600_000) })
  for (const item of done.items) lines.push(`${item.identifier},${item.status},${item.media_url ?? ''}`)
  console.log(`Rows ${start + 2}+: ${done.status}, ${done.failed} failed`)
}

writeFileSync('images.csv', lines.join('\n') + '\n')

```

Run it:

```bash
SNAPSBREW_URL=https://snapsbrew.example \
SNAPSBREW_TOKEN=<api-token> \
TEMPLATE_ID=<template-uuid> \
SHEET_CSV_URL='https://docs.google.com/spreadsheets/d/e/<id>/pub?output=csv' \
node sheet-to-images.mjs

```

The row number in `identifier` is the row number in the sheet, so you can paste `images.csv` back next to your data.

### What the script relies on

- **100 items for each batch.** A batch with more items gets a `422` error and the instance creates nothing. The script splits the rows.
- **Batches run in the background.** `batches.wait()` reads the batch every 5 seconds until the status is `completed`, `failed` or `canceled`.
- **A `completed` batch can have failed items.** Read the `failed` count and the `status` of each item, not only the status of the batch.
- **The rate limit is 60 API requests a minute for each user.** One batch and its status checks stay far under it.
- **Safe retries.** If the script can run twice for the same rows, send an `idempotency_key` with each batch. A retry with the same key returns the same batch for 24 hours.

## Images or PDFs for print

For certificates, tickets and badges, a PDF is often better than a PNG. Send `type: 'pdf'` with the batch. Each item of one batch has the same type and format. Read [How to generate custom certificates with the API](https://snapsbrew.com/guides/generate-custom-certificates-with-api.md) for a full example.

## Questions

How many rows can one import have?

The upload limit is a 10 MB file in `.xlsx`, `.xls` or `.csv` format. The API takes 100 items for each batch, so a script splits a long sheet into batches of 100.

What happens with an empty cell?

The layer keeps the value of the template. So you can leave a column empty in the rows that need the default.

Can a row make a PDF instead of an image?

Yes. With the API, send `"type":"pdf"` with the batch. Each item of a batch has the same type and format, so put PNG rows and PDF rows in two batches.

Do I get a notice when the import ends?

Yes. The instance emails the person who started the batch. If the batch has a `webhook_url`, the instance also posts a `snap-import.completed`, `snap-import.failed` or `snap-import.canceled` event to it.

## Related pages

- [Docs: Batches and imports](https://snapsbrew.com/docs/using-snapsbrew/batches.md)
- [Docs: Snap batches API](https://snapsbrew.com/docs/api/snap-batches.md)
- [How to automate social images from a CMS or a spreadsheet](https://snapsbrew.com/blog/automate-social-images-from-cms-or-spreadsheet.md)
- [How to generate custom certificates with the API](https://snapsbrew.com/guides/generate-custom-certificates-with-api.md)
- [How to generate images from an AI agent with MCP](https://snapsbrew.com/guides/generate-images-with-ai-agent-mcp.md)

## Run it on your own server

Docker Compose starts the app, the queue, MySQL, Redis and the renderer together.

[Self-host it](https://snapsbrew.com/docs/getting-started/installation-docker.md) [View on GitHub](https://github.com/amedina068/snapsbrew)

```bash
git clone https://github.com/amedina068/snapsbrew.git
cd snapsbrew
cp .env.docker.example .env   # then fill in .env
docker compose up -d --build
```
