Dynamic Open Graph social preview images made simple.
open-graph-maker is a Node.js tool for automatically generating Open Graph (OG) images using custom templates, fonts, and dynamic content. It’s flexible enough for blogs, SaaS apps, SEO projects, marketing pages, documentation sites, and more.
- ⚡ Lightning-fast image generation with Node.js and Canvas
- 🖼️ Dynamic text rendering: titles, taglines, and descriptions
- 🎨 Fully customizable templates, fonts, and styles
- 🛠️ CLI support with
--limitoption for batch control - 📦 Easy JSON-based content input
- 📂 Outputs high-quality PNG files to a local directory
Before running open-graph-maker, make sure you have:
- Node.js 18.x or newer installed
- Required fonts placed inside the
/fontsdirectory - A
data.jsonfile containing your input data
To create beautiful Open Graph images with open-graph-maker, you'll need a base template image that defines your static layout.
- Design your layout in Figma (or your preferred design tool).
- Keep all static elements — such as background colors, logos, decorative text, or branding.
- Remove dynamic content — such as the title, tagline, and description that will change for each image.
- Optionally, leave empty text boxes positioned and styled where dynamic content will be inserted later. (This helps guide your script.)
Example:
Static elements = Logo, background, permanent brand slogans
Dynamic elements = Title, tagline, description for each page or item
- Export the base layout as a PNG or JPG file.
- Save it into your project directory (e.g.,
template.png).
In your Node.js script:
- Load the base template as the background image.
- Draw dynamic text onto the canvas at the exact X/Y positions you designed.
- Match font families, sizes, colors, and alignments based on your original design.
You will need to know:
- X and Y coordinates for each text block
- Font sizes, line heights, and text spacing
- Font families and weights
- Text alignment and color codes
If your Open Graph images also need an illustration, avatar, product image, or other dynamic graphic:
-
Shared Graphic:
If all images use the same graphic, embed it directly into your base template. -
Dynamic Graphic:
If each image has a different graphic, dynamically load the appropriate image in your Node script and position it accordingly.
The data.json file must be structured as an array of objects under a data key, where each object includes:
title(required) — the main heading for the Open Graph imagetagline(required) — a short, catchy subheading displayed under the titledescription(required) — a longer supporting description typically shown smaller
{
"data": [
{
"title": "Ron Swanson",
"tagline": "Give me all the bacon and eggs you have. And a glass of Scotch.",
"description": "Director of the Parks Department. Lover of woodworking, whiskey, and freedom."
},
{
"title": "Leslie Knope",
"tagline": "Friends, waffles, and work. But work has to come third.",
"description": "Deputy Director of Parks and Recreation. Binder enthusiast and eternal optimist."
},
{
"title": "Andy Dwyer",
"tagline": "Burt Macklin, FBI!",
"description": "Shoeshiner, rockstar, and part-time secret agent. Lead singer of Mouse Rat."
}
]
}Important:
All three fields —title,tagline, anddescription— are required for each item.
You can easily modify what appears on each Open Graph image by editing the values inside your data.json file.
- Update the
titleto change the main headline. - Change the
taglinefor a different subheadline or style. - Edit the
descriptionto add supporting context, character bios, product blurbs, quotes, or anything else. - Add or remove entries to control how many images are generated.
Every time you update data.json, simply re-run the script to generate fresh images:
node generate-og-images.jsgit clone <repository-url>
cd open-graph-maker
npm installnode generate-og-images.jsnode generate-og-images.js --limit 5open-graph-maker/
├── fonts/ # Required font files
├── output/ # Output directory for generated images
├── generate-og-images.js # Main generation script
├── data.json # Your input data
├── template.png # Background template image
├── package.json # Project dependencies
└── README.md # This file
- Template Image — Replace
template.pngwith your own background image. - Fonts — Place new
.ttfor.otffiles in/fontsand update the font settings insidegenerate-og-images.js. - Layout / Colors — Adjust text positions, colors, and sizes directly in the script.
MIT License.
See LICENSE for full details.
Created by Aaron K. White.
PRs, forks, stars, and collaborations are welcome! 🚀
