Generate Images from JSON Data with an API

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, Python, 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 and how to adapt it to any data source. All pricing below is as of March 2026.

How json maps to imagesHow 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 templateThe 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 jsonThe 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 callThe API Call

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 layerAvailable Properties Per Layer

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

Text layersText Layers

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

Image layersImage Layers

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

Shape layersShape Layers

{
  "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 languageCode Examples in Every Language

NodejsNode.js

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))

PythonPython

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)

PhpPHP

$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 bashcURL (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 alternativeGET Request Alternative

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

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.

Real world pattern json from a databaseReal-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.

// 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 codeNo-Code: JSON Without Writing Code

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 mistakesCommon 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 startedGetting Started

  1. Sign up for 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.

For batch generation from spreadsheets, see our Batch Image Generation from CSV guide. For pricing across providers, check our Image Generation API Pricing Comparison. And for more use cases, see Dynamic Product Images.

FaqFAQ

Can i generate images from json dataCan I generate images from JSON data?

Yes. APIs like 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 expectWhat 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 codingCan I generate images from JSON without coding?

Yes. Zapier, Make, and n8n all support HTTP requests with JSON bodies. Map your data fields in the visual builder.

How many images can i generate from json per minuteHow 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 covers 10,000 images per month at $24.99.

What programming languages work with json image apisWhat 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 with JSON input, fully language-agnostic.

Start generatingStart 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 and generate your first image from JSON today.