Meme Generator API

Generate custom memes programmatically with our simple REST API

Table of Contents

Overview

The Meme Generator API allows you to programmatically generate meme images with custom text, backgrounds, and styling. Perfect for automating meme creation, social media bots, or integrating meme generation into your applications.

Key Features:
  • No authentication required - completely public API
  • Up to 5 text layers per meme
  • Three background types: solid colors, gradients, or template images
  • Advanced text styling: fonts, colors, shadows, outlines
  • Automatic text wrapping
  • Returns PNG images directly

API Endpoint

POST https://websitetool.org/api/meme-generator/generate

Authentication

No authentication is required. The API is completely public and free to use.

Note: Rate limiting is in place to prevent abuse. See Rate Limits for details.

Request Format

Send a POST request with a JSON body containing your meme parameters.

Headers

Content-Type: application/json

Request Body Structure

{
  "width": 800,
  "height": 600,
  "bgType": "solid",
  "bgColor": "#3b82f6",
  "layers": [
    {
      "text": "Your meme text here",
      "x": 400,
      "y": 300,
      "fontFamily": "Impact",
      "fontSize": 48,
      "color": "#ffffff",
      "align": "center",
      "shadow": true,
      "stroke": true
    }
  ]
}

Parameters

Canvas Parameters

Parameter Type Required Description
width integer Required Canvas width in pixels (100-4000)
height integer Required Canvas height in pixels (100-4000)
bgType string Required Background type: "solid", "gradient", or "image"
layers array Required Array of text layer objects (1-5 layers)

Background Parameters (Solid)

When bgType is "solid":

Parameter Type Required Description
bgColor string Optional Hex color code (e.g., "#3b82f6"). Default: "#3b82f6"

Background Parameters (Gradient)

When bgType is "gradient":

Parameter Type Required Description
gradientStart string Optional Starting hex color (e.g., "#3b82f6"). Default: "#3b82f6"
gradientEnd string Optional Ending hex color (e.g., "#8b5cf6"). Default: "#8b5cf6"
gradientAngle integer Optional Gradient angle in degrees (0-360). Default: 45

Background Parameters (Image)

When bgType is "image":

Parameter Type Required Description
bgImage string Optional Background template filename (e.g., "drake.png"). See available templates

Text Layer Parameters

Each object in the layers array can have the following properties:

Parameter Type Required Description
text string Required The text to display (max 5000 characters)
x integer Optional X coordinate position. Default: center of canvas
y integer Optional Y coordinate position. Default: center of canvas
fontFamily string Optional Font family. Options: "Arial", "Impact", "Times New Roman", "Courier New", "Verdana", "Comic Sans MS". Default: "Impact"
fontSize integer Optional Font size in pixels (1-500). Default: 48
color string Optional Text color as hex (e.g., "#ffffff"). Default: "#ffffff"
bold boolean Optional Use bold font variant. Default: false
italic boolean Optional Use italic font variant. Default: false
align string Optional Text alignment: "left", "center", or "right". Default: "center"
shadow boolean Optional Enable text shadow. Default: false
shadowBlur integer Optional Shadow blur amount (0-30). Default: 5
shadowColor string Optional Shadow color as hex. Default: "#000000"
stroke boolean Optional Enable text outline/stroke. Default: false
strokeWidth integer Optional Stroke width in pixels (1-20). Default: 2
strokeColor string Optional Stroke color as hex. Default: "#000000"

Response Format

Success Response

200 OK

Returns the generated meme as a PNG image binary.

Content-Type: image/png
Content-Disposition: inline; filename="meme.png"

[PNG binary data]

Error Responses

400 Bad Request - Invalid parameters

{
  "success": false,
  "error": "Invalid parameter: Width must be between 100 and 4000, got 5000"
}

404 Not Found - Background template not found

{
  "success": false,
  "error": "Background template not found: nonexistent.png"
}

500 Internal Server Error - Server error during generation

{
  "success": false,
  "error": "Error generating meme: [error details]"
}

Code Examples

JavaScript (Fetch API)

async function generateMeme() {
  const response = await fetch('https://websitetool.org/api/meme-generator/generate', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      width: 800,
      height: 600,
      bgType: 'gradient',
      gradientStart: '#3b82f6',
      gradientEnd: '#8b5cf6',
      gradientAngle: 45,
      layers: [
        {
          text: 'When you successfully',
          x: 400,
          y: 200,
          fontFamily: 'Impact',
          fontSize: 48,
          color: '#ffffff',
          align: 'center',
          shadow: true,
          shadowBlur: 5,
          shadowColor: '#000000',
          stroke: true,
          strokeWidth: 2,
          strokeColor: '#000000'
        },
        {
          text: 'Call an API',
          x: 400,
          y: 400,
          fontFamily: 'Impact',
          fontSize: 48,
          color: '#ffffff',
          align: 'center',
          shadow: true,
          shadowBlur: 5,
          shadowColor: '#000000',
          stroke: true,
          strokeWidth: 2,
          strokeColor: '#000000'
        }
      ]
    })
  });

  if (response.ok) {
    const blob = await response.blob();
    const img = document.getElementById('meme-image');
    img.src = URL.createObjectURL(blob);
  } else {
    const error = await response.json();
    console.error('Error:', error.error);
  }
}

generateMeme();

Python (Requests)

import requests

url = 'https://websitetool.org/api/meme-generator/generate'

payload = {
    'width': 800,
    'height': 600,
    'bgType': 'solid',
    'bgColor': '#3b82f6',
    'layers': [
        {
            'text': 'Python Meme',
            'x': 400,
            'y': 300,
            'fontFamily': 'Impact',
            'fontSize': 48,
            'color': '#ffffff',
            'align': 'center',
            'shadow': True,
            'shadowBlur': 5,
            'shadowColor': '#000000',
            'stroke': True,
            'strokeWidth': 2,
            'strokeColor': '#000000'
        }
    ]
}

response = requests.post(url, json=payload)

if response.status_code == 200:
    with open('meme.png', 'wb') as f:
        f.write(response.content)
    print('Meme saved as meme.png')
else:
    print(f'Error: {response.json()["error"]}')

PHP (cURL)

<?php
$url = 'https://websitetool.org/api/meme-generator/generate';

$data = [
    'width' => 800,
    'height' => 600,
    'bgType' => 'solid',
    'bgColor' => '#3b82f6',
    'layers' => [
        [
            'text' => 'PHP Meme',
            'x' => 400,
            'y' => 300,
            'fontFamily' => 'Impact',
            'fontSize' => 48,
            'color' => '#ffffff',
            'align' => 'center',
            'shadow' => true,
            'shadowBlur' => 5,
            'shadowColor' => '#000000',
            'stroke' => true,
            'strokeWidth' => 2,
            'strokeColor' => '#000000'
        ]
    ]
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($httpCode === 200) {
    file_put_contents('meme.png', $response);
    echo 'Meme saved as meme.png';
} else {
    $error = json_decode($response, true);
    echo 'Error: ' . $error['error'];
}
?>

cURL (Command Line)

curl -X POST https://websitetool.org/api/meme-generator/generate \
  -H "Content-Type: application/json" \
  -d '{
    "width": 800,
    "height": 600,
    "bgType": "solid",
    "bgColor": "#3b82f6",
    "layers": [
      {
        "text": "My Meme Text",
        "x": 400,
        "y": 300,
        "fontFamily": "Impact",
        "fontSize": 48,
        "color": "#ffffff",
        "align": "center",
        "shadow": true,
        "shadowBlur": 5,
        "shadowColor": "#000000",
        "stroke": true,
        "strokeWidth": 2,
        "strokeColor": "#000000"
      }
    ]
  }' \
  --output meme.png

Error Codes

HTTP Code Error Type Description
400 Bad Request Invalid parameters (missing fields, invalid values, etc.)
404 Not Found Background template image not found
500 Server Error Internal error during meme generation

Common Validation Errors

Rate Limits

The API is rate-limited to prevent abuse:

Note: If you need higher rate limits for production use, please contact us.

Background Templates

The following meme template backgrounds are available for use with bgType: "image":

Note: Template images are currently being populated. Available templates will be listed here once added.

Planned Templates

Using Custom Backgrounds

For now, only predefined templates are supported. Custom image uploads are not available via the API to maintain security and performance.

Best Practices

Text Positioning

Text Styling

Canvas Sizes

Performance

Support & Feedback

If you encounter any issues or have suggestions for improvements, please contact us.

Interactive Meme Generator: Try out the visual meme generator at websitetool.org/meme-generator/ to experiment with different settings before using the API.