---
title: "Generate Images from JSON Data with an API"
description: "Turn JSON data into images with a single API call. Map data fields to template layers and generate at scale. Works with any programming language or no-code."
url: "https://www.imejis.io/blogs/tutorials/generate-images-from-json"
published: "2026-03-22"
---

# Generate Images from JSON Data with an API

Generating images from JSON is a single API call: POST your data as a JSON object, get a rendered image back in under 2 seconds. Every template image API works this way, and it's the simplest path from structured data to visual content.

I've built this workflow in [Node.js](/blogs/node-js-integration), [Python](/blogs/tutorials/python-image-api-integration), PHP, and even bash scripts. The pattern is always the same. I tested it most recently with a product catalog of 800 items, and the whole thing generated in about 25 minutes. Here's how it works with [Imejis.io](https://www.imejis.io) and how to adapt it to any data source. All pricing below is as of March 2026.

## How JSON Maps to Images

Think of your image template as a form with named fields. Each field has a name (like "headline" or "product_image") and accepts specific properties (text content, image URL, color, opacity). Your JSON mirrors that structure.

### The Template

A template in Imejis.io might have these layers:

- `headline`: a text layer for the main title
- `subtitle`: a text layer for secondary text
- `product_image`: an image layer for a photo
- `background`: a shape layer with a fill color
- `price_badge`: a text layer for pricing

### The JSON

```json
{
  "headline": {
    "text": "Summer Collection 2026",
    "color": "#ffffff"
  },
  "subtitle": {
    "text": "New arrivals starting at $19.99"
  },
  "product_image": {
    "image": "https://yourstore.com/photos/jacket-blue.jpg"
  },
  "background": {
    "fillColor": "#1a1a2e"
  },
  "price_badge": {
    "text": "$19.99"
  }
}
```

Each key matches a layer name in the template. Each value contains the properties you want to change. You only need to include the fields you want to update. Everything else stays as designed in the template.

### The API Call

```bash
curl -X POST 'https://render.imejis.io/v1/YOUR_TEMPLATE_ID' \
  -H 'dma-api-key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "headline": { "text": "Summer Collection 2026", "color": "#ffffff" },
    "subtitle": { "text": "New arrivals starting at $19.99" },
    "product_image": { "image": "https://yourstore.com/photos/jacket-blue.jpg" },
    "background": { "fillColor": "#1a1a2e" },
    "price_badge": { "text": "$19.99" }
  }'
```

The response is the image itself. Not a JSON payload with a URL to poll. The actual rendered PNG, returned directly. Under 2 seconds.

## Available Properties Per Layer

You can control more than just text and images. Here's what each layer type accepts:

### Text Layers

```json
{
  "headline": {
    "text": "Your content here",
    "color": "#ffffff",
    "opacity": 0.9
  }
}
```

### Image Layers

```json
{
  "product_photo": {
    "image": "https://example.com/photo.jpg"
  }
}
```

### Shape Layers

```json
{
  "background_box": {
    "fillColor": "#ff6b35",
    "borderColor": "#333333",
    "opacity": 0.8
  }
}
```

You only send the properties you want to change. If your template has a headline with a default font size and you only want to change the text, just send `{"headline": {"text": "New text"}}`. The font size stays as designed.

## Code Examples in Every Language

### Node.js

```javascript
const response = await fetch(`https://render.imejis.io/v1/${templateId}`, {
  method: "POST",
  headers: {
    "dma-api-key": apiKey,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    headline: { text: "Summer Collection 2026" },
    price: { text: "$19.99" },
  }),
})

const imageBuffer = await response.arrayBuffer()
fs.writeFileSync("output.png", Buffer.from(imageBuffer))
```

### Python

```python
import requests

response = requests.post(
    f'https://render.imejis.io/v1/{template_id}',
    headers={
        'dma-api-key': api_key,
        'Content-Type': 'application/json'
    },
    json={
        'headline': {'text': 'Summer Collection 2026'},
        'price': {'text': '$19.99'}
    }
)

with open('output.png', 'wb') as f:
    f.write(response.content)
```

### PHP

```php
$ch = curl_init("https://render.imejis.io/v1/{$templateId}");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'dma-api-key: ' . $apiKey,
        'Content-Type: application/json'
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'headline' => ['text' => 'Summer Collection 2026'],
        'price' => ['text' => '$19.99']
    ])
]);

$image = curl_exec($ch);
file_put_contents('output.png', $image);
```

### cURL (Bash)

```bash
curl -X POST "https://render.imejis.io/v1/YOUR_TEMPLATE_ID" \
  -H "dma-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"headline": {"text": "Summer Collection 2026"}}' \
  --output output.png
```

Same JSON structure, any language. If it can make an HTTP POST with a JSON body, it works.

## GET Request Alternative

For simpler use cases, you can also generate images via URL query parameters:

```text
https://render.imejis.io/v1/YOUR_TEMPLATE_ID?dma-api-key=YOUR_API_KEY&headline.text=Summer+Collection&price.text=$19.99
```

This is useful for embedding dynamic images directly in HTML, emails, or Notion pages where you can't make POST requests. Just construct the URL and use it as an `img` tag source. For a practical example, see [generate OG images dynamically](/blogs/tutorials/generate-og-images-dynamically).

## Real-World Pattern: JSON from a Database

Most real use cases don't hardcode JSON. You pull data from a database, API, or spreadsheet and transform it into the image API's format.

```javascript
// Pull product data from your database
const products = await db.query("SELECT * FROM products WHERE on_sale = true")

// Transform each product into image API JSON
for (const product of products) {
  const imageJson = {
    product_name: { text: product.name },
    product_image: { image: product.imageUrl },
    price: { text: `$${product.salePrice.toFixed(2)}` },
    original_price: { text: `$${product.originalPrice.toFixed(2)}` },
    discount_badge: {
      text: `${Math.round(
        (1 - product.salePrice / product.originalPrice) * 100
      )}% OFF`,
    },
  }

  const response = await fetch(`https://render.imejis.io/v1/${TEMPLATE_ID}`, {
    method: "POST",
    headers: {
      "dma-api-key": API_KEY,
      "Content-Type": "application/json",
    },
    body: JSON.stringify(imageJson),
  })

  const buffer = await response.arrayBuffer()
  await fs.writeFile(`output/${product.id}.png`, Buffer.from(buffer))
}
```

The data transformation is the only custom part. I find this pattern works for any data source: databases, APIs, spreadsheets, CMS webhooks. The API call is identical every time.

## No-Code: JSON Without Writing Code

Better still, let an AI agent write the JSON and make the call. Ask Claude or ChatGPT for the image and it maps your data to the template. See the [AI Agents](/agents) path.

Don't want to code? Zapier, Make, and n8n all support HTTP requests with JSON bodies.

**In Make.com:**

1. Add an HTTP "Make a request" module
2. Set method to POST
3. Set URL to `https://render.imejis.io/v1/YOUR_TEMPLATE_ID`
4. Add header: `dma-api-key: YOUR_API_KEY`
5. Set body type to JSON
6. Map your data fields to the JSON structure

**In n8n:**

1. Add an HTTP Request node
2. Configure POST to the API URL
3. Map fields from your trigger (Google Sheets row, Airtable record, webhook payload)
4. The response contains the image binary

The JSON structure is the same whether you write it in Python or drag it together in a no-code builder.

## Common Mistakes

**Sending the wrong layer name.** If your template has a layer called `main_title` and you send `{"title": {"text": "..."}}`, nothing happens. Check your template's layer names in the editor.

**Forgetting the Content-Type header.** Without `Content-Type: application/json`, the API can't parse your payload. Always include it.

**Sending nested objects too deep.** The structure is two levels: layer name, then properties. Don't nest further than `{"layerName": {"property": "value"}}`.

**Not URL-encoding GET requests.** If you use the GET method with query parameters, spaces and special characters need URL encoding. `$19.99` becomes `%2419.99`.

## Getting Started

1. **[Sign up for Imejis.io](https://app.imejis.io)**: 100 free API calls per month
2. **Create a template** in the drag-and-drop editor
3. **Note the layer names**: these become your JSON keys
4. **Send a test JSON payload** using cURL or your preferred language
5. **Verify the output** matches your design
6. **Connect your data source** and generate at scale

The whole process takes about 30 minutes from signup to first generated image. If you haven't used an image API before, start with our [beginner guide to generating images with an API](/blogs/tutorials/how-to-generate-images-with-api).

For batch generation from spreadsheets, see our [Batch Image Generation from CSV](/blogs/tutorials/batch-image-generation-csv) guide. For pricing across providers, check our [Image Generation API Pricing Comparison](/blogs/comparisons/image-generation-api-pricing-comparison). And for more use cases, see [Dynamic Product Images](/blogs/use-cases/dynamic-product-images-pricing).

## FAQ

### Can I generate images from JSON data?

Yes. APIs like [Imejis.io](https://www.imejis.io) accept JSON where each key maps to a template layer. Send your data, get a rendered image back in under 2 seconds.

### What JSON format does an image API expect?

A nested object: layer name as key, properties as value. Example: `{"headline": {"text": "Hello"}, "background": {"fillColor": "#1a1a2e"}}`. Only include fields you want to change.

### Can I generate images from JSON without coding?

Yes. [Zapier](https://zapier.com), [Make](https://www.make.com), and [n8n](https://n8n.io) all support HTTP requests with JSON bodies. Map your data fields in the visual builder.

### How many images can I generate from JSON per minute?

About 30 sequentially (each takes under 2 seconds). With parallel requests, much more. [Imejis.io Pro](https://www.imejis.io/pricing) covers 10,000 images per month at $24.99.

### What programming languages work with JSON image APIs?

Any language that makes HTTP requests: JavaScript, Python, PHP, Ruby, Go, Java, C#, Rust. The API is [REST-based](https://www.imejis.io/apis) with JSON input, fully language-agnostic.

## Start Generating

Your data is already structured. Your template is a 10-minute design job. The API call is 5 lines of code. [Try Imejis.io free](https://app.imejis.io) and generate your first image from JSON today.
