Generate custom memes programmatically with our simple REST API
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.
No authentication is required. The API is completely public and free to use.
Send a POST request with a JSON body containing your meme parameters.
Content-Type: application/json
{
"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
}
]
}
| 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) |
When bgType is "solid":
| Parameter | Type | Required | Description |
|---|---|---|---|
| bgColor | string | Optional | Hex color code (e.g., "#3b82f6"). Default: "#3b82f6" |
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 |
When bgType is "image":
| Parameter | Type | Required | Description |
|---|---|---|---|
| bgImage | string | Optional | Background template filename (e.g., "drake.png"). See available templates |
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" |
200 OK
Returns the generated meme as a PNG image binary.
Content-Type: image/png Content-Disposition: inline; filename="meme.png" [PNG binary data]
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]"
}
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();
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
$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 -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
| 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 |
Missing required field: [field] - Required parameter not providedWidth must be between 100 and 4000 - Canvas width out of rangeHeight must be between 100 and 4000 - Canvas height out of rangeMust have between 1 and 5 layers - Too many or too few text layersLayer [n] missing required field: text - Text layer missing textLayer [n] text exceeds 5000 characters - Text too longLayer [n] fontSize must be between 1 and 500 - Font size out of rangeLayer [n] color must be a valid hex color - Invalid color formatbgType must be solid, gradient, or image - Invalid background typeThe API is rate-limited to prevent abuse:
The following meme template backgrounds are available for use with bgType: "image":
drake.png - Drake Hotline Blingdistracted-boyfriend.png - Distracted Boyfriendwoman-yelling-cat.png - Woman Yelling at Catchange-my-mind.png - Change My Mindsuccess-kid.png - Success Kiddisaster-girl.png - Disaster Girlexpanding-brain.png - Expanding Brainis-this-pigeon.png - Is This a Pigeonsurprised-pikachu.png - Surprised Pikachutwo-buttons.png - Two Buttonsbernie-sanders.png - Bernie Sanders (Mittens)one-does-not-simply.png - One Does Not SimplyFor now, only predefined templates are supported. Custom image uploads are not available via the API to maintain security and performance.
align: "center" and set x to half the canvas width for centered texty to about 15-20% of canvas heighty to about 80-85% of canvas heightfontFamily: "Impact" with white text (#ffffff)stroke: true, strokeColor: "#000000", strokeWidth: 2-4shadow: true, shadowBlur: 4-8If you encounter any issues or have suggestions for improvements, please contact us.