Beautiful Open Graph ImagesGenerated on Demand
Create stunning, customizable Open Graph images for your websites and applications. No design skills required – just construct a URL and get professional results instantly.
Required: title only. All other parameters are optional.
Defaults: theme=light, template=default if not provided.
How the OG Image API Works
The OG Image API lets you generate beautiful, dynamic Open Graph images for your website, blog, or app. Only the title parameter is required. All other parameters are optional and have sensible defaults. You can customize the look and feel with theme, template, subtitle, logoUrl, author, and more.
- Required:
title(the main text for your image) - Optional:
theme(light/dark, default: light),template(default/simple /article /blog /gradient /neon /professional, default: default),subtitle,logoUrl,author,authorImageUrl,background,pattern,backgroundImage,format(png/svg, default: png)
Base URL:
Code Example in bash
https://www.readmecodegen.com/api/og-generatorMinimal Example:
Code Example in bash
https://www.readmecodegen.com/api/og-generator?title=Hello%20WorldAdvanced Example:
Code Example in bash
https://www.readmecodegen.com/api/og-generator?title=Launch%20Event&subtitle=Join%20us%20for%20the%20biggest%20launch&theme=dark&template=professional&logoUrl=https://example.com/logo.pngTip: You only need to add parameters if you want to override the defaults or add extra info. The API will always work with just a title.
Get Started in Minutes
Three simple steps to generate your first OG image
API Reference
Simple RESTful interface – just construct a URL with query parameters and get a PNG image back.
Code Example in bash
GET https://www.readmecodegen.com/api/og-generatorAll Parameters at a Glance
| Parameter | Type | Description | Templates |
|---|---|---|---|
| title | string | Main title text Required | All |
| theme | string | Color theme (light or dark). Optional, defaults to light. | All |
| template | string | Design template (default, simple, etc). Optional, defaults to default. | All |
| subtitle | string | Secondary text line | default, simple, professional, article, blog |
| logoUrl | string (URL) | Brand or site logo | All except gradient, neon |
| author | string | Author name | article, blog |
| authorImageUrl | string (URL) | Author profile image | article, blog |
| background | string (CSS) | Custom CSS background | All |
| pattern | string | Predefined background pattern | All |
| backgroundImage | string (URL) | Background image URL | All |
| format | png/svg | Image format | All |
Query Parameters
titleThe main title text for your OG image
templateChoose the overall layout and design style
Defaults to default
themeColor scheme for the image
Defaults to light
subtitleSecondary text line
Used by: default, simple, professional, article, blog template(s)
authorAuthor's name
Used by: article, blog template(s)
authorImageUrlURL for author's profile picture
Used by: article, blog template(s)
logoUrlURL for your brand logo
Used by: All except gradient, neon template(s)
Background & Format Options
Code Example in bash
https://www.readmecodegen.com/api/og-generator?title=Custom%20BG&background=linear-gradient(135deg,#667eea,#764ba2)Code Example in bash
https://www.readmecodegen.com/api/og-generator?title=Pattern%20BG&pattern=geometricCode Example in bash
https://www.readmecodegen.com/api/og-generator?title=Image%20BG&backgroundImage=https://images.unsplash.com/photo-1506744038136-46273834b3fbCode Example in bash
https://www.readmecodegen.com/api/og-generator?title=PNG%20FormatCode Example in bash
https://www.readmecodegen.com/api/og-generator?template=professional&theme=dark&title=Building%20a%20World-Class%20API&subtitle=Lessons%20Learned%20in%20Scalability%20and%20DesignIntegration Guides
Step-by-step instructions for popular frameworks and platforms
Note: Only title is required for the OG image API. All other parameters are optional and default to theme=light and template=default unless you specify otherwise.
Add the OG image URL directly to your page's static metadata object.
Code Example in typescript
// app/page.tsx
import { Metadata } from 'next';
const PAGE_TITLE = 'Home';
export const metadata: Metadata = {
title: PAGE_TITLE,
description: 'Welcome to our amazing site.',
alternates: {
canonical: `https://yoursite.com/`,
},
openGraph: {
title: PAGE_TITLE,
description: 'Welcome to our amazing site.',
url: `https://yoursite.com/`,
images: [{ url: `https://www.readmecodegen.com/api/og-generator?title=${encodeURIComponent(PAGE_TITLE)}` }]
},
twitter: {
card: 'summary_large_image',
title: PAGE_TITLE,
description: 'Welcome to our amazing site.',
images: [`https://www.readmecodegen.com/api/og-generator?title=${encodeURIComponent(PAGE_TITLE)}`]
}
};metadata and the OG image URL.Step 1: Create the helper file
Code Example in typescript
// lib/metadata.ts
import { Metadata } from 'next';
const SITE_URL = 'https://yoursite.com';
function getOgImageUrl(title: string, options?: {
template?: string;
theme?: string;
subtitle?: string;
}) {
const params = new URLSearchParams({ title, ...options });
return `https://www.readmecodegen.com/api/og-generator?${params.toString()}`;
}
export function generatePageMetadata(data: {
title: string;
description: string;
path: string;
ogOptions?: Parameters<typeof getOgImageUrl>[1];
}): Metadata {
const { title, description, path, ogOptions } = data;
const imageUrl = getOgImageUrl(title, ogOptions);
const pageUrl = SITE_URL + path;
return {
title,
description,
alternates: {
canonical: pageUrl,
},
openGraph: {
title,
description,
url: pageUrl,
images: [{ url: imageUrl }],
},
twitter: {
card: "summary_large_image",
title,
description,
images: [imageUrl],
},
};
}Step 2: Use in your pages
Code Example in typescript
// app/about/page.tsx
import { generatePageMetadata } from '@/lib/metadata';
export const metadata = generatePageMetadata({
title: 'About Us',
description: 'Learn more about our company mission and team.',
path: '/about',
ogOptions: {
template: 'professional',
theme: 'dark'
}
});
export default function AboutPage() {
return <div>... your amazing about page ...</div>;
}Code Example in typescript
// app/blog/[slug]/page.tsx
import { Metadata } from 'next';
async function getPost(slug: string) {
const res = await fetch(`https://api.yoursite.com/posts/${slug}`);
if (!res.ok) throw new Error('Failed to fetch post');
return res.json();
}
function getDynamicOgUrl(title: string, author?: string) {
const params = new URLSearchParams({
title,
template: 'article',
...(author && { author })
});
return `https://www.readmecodegen.com/api/og-generator?${params.toString()}`;
}
export async function generateMetadata({
params
}: {
params: { slug: string }
}): Promise<Metadata> {
const post = await getPost(params.slug);
const ogImageUrl = getDynamicOgUrl(post.title, post.author);
return {
title: post.title,
description: post.excerpt,
openGraph: {
title: post.title,
description: post.excerpt,
url: `https://yoursite.com/blog/${params.slug}`,
images: [{ url: ogImageUrl }],
type: 'article',
authors: [post.author],
},
twitter: {
card: "summary_large_image",
title: post.title,
description: post.excerpt,
images: [ogImageUrl],
},
};
}Ready to Get Started?
Try the API now and see how easy it is to generate beautiful OG images for your projects.
Code Example in bash
https://www.readmecodegen.com/api/og-generator?title=My%20First%20OG%20Image&template=professional&theme=darkFull Code Guide
Minimal Example (Only Required)
Code Example in bash
https://www.readmecodegen.com/api/og-generator?title=My%20First%20OG%20ImageAdvanced Example (With Optional Parameters)
Code Example in bash
https://www.readmecodegen.com/api/og-generator?title=My%20First%20OG%20Image&theme=dark&template=professional&subtitle=Optional%20SubtitleYou only need to add parameters if you want to override the defaults or add extra info.
Step-by-Step Usage Guide
- Choose your title: This is the only required parameter. Example:
title=My%20Awesome%20Blog - Pick a template (optional): Use
template=default,simple,article,blog,gradient,neon, orprofessionalfor different styles. - Set a theme (optional): Use
theme=lightortheme=dark. - Add branding (optional): Use
logoUrlfor your logo,authorandauthorImageUrlfor author info. - Customize background (optional): Use
backgroundfor a CSS gradient,patternfor a preset, orbackgroundImagefor a custom image. - Choose output format (optional): Use
format=svgfor SVG, otherwise PNG is default. - Copy and use the generated URL: Paste it in your meta tags, social cards, or anywhere you need an OG image.
Best Practice: Always test your OG image in Facebook, Twitter, and LinkedIn preview tools to ensure it looks great everywhere!
Branding & Author Info
Tip: You can personalize your OG images by adding your logo and author details.
Code Example in bash
https://www.readmecodegen.com/api/og-generator?title=My%20Blog%20Post&logoUrl=https://www.readmecodegen.com/logo.png&author=Jane%20Doe&authorImageUrl=https://example.com/jane.jpg- logoUrl: URL to your brand or site logo (PNG, SVG, or JPG).
- author: Name of the author (shown on article/blog templates).
- authorImageUrl: URL to the author's profile image (shown on article/blog templates).
How to Sync OG Image Title with Your Page Title
Important: The OG Image API does not automatically fetch your page's <title> or meta title. You must explicitly pass the title parameter in the OG image URL. This ensures your OG image always displays the correct text.
Static HTML Example
Code Example in html
<title>My Static Page</title>
<meta property="og:title" content="My Static Page">
<meta property="og:image" content="https://www.readmecodegen.com/api/og-generator?title=My%20Static%20Page" />Tip: Always keep the <title>, og:title, and the title parameter in the OG image URL in sync.
Dynamic Example (Next.js/React)
Code Example in typescript
// Next.js App Router example
import { Metadata } from 'next';
export const metadata: Metadata = {
title: 'My Dynamic Page',
openGraph: {
title: 'My Dynamic Page',
images: [
{
url: 'https://www.readmecodegen.com/api/og-generator?title=My%20Dynamic%20Page',
},
],
},
};Best Practice: Use the same variable for your page title and the OG image title parameter to keep them in sync.