Last month I wanted to add meme generation to a side project. Every meme API I found was either paid, rate-limited to hell, or had maybe 50 templates.
So I built my own. justmeme.wtf has 2,300+ meme templates, a free API, and runs entirely on Cloudflare Workers + D1.
Here's how it works and what I learned.
The Stack
- Cloudflare Workers — handles all routing, SSR, and image generation
- Cloudflare D1 — stores 2,300+ meme templates with metadata
- Canvas API — server-side text rendering on meme images
- No framework — vanilla JS, single index.js file
Total monthly cost: $0 (Cloudflare free tier covers it).
The API
The API is completely free, no auth required. Here's what you can do:
Get all templates
curl https://justmeme.wtf/api/v1/templates
Returns every template with its slug, name, text box count, and dimensions.
Get a specific template
curl https://justmeme.wtf/api/v1/templates/drake-hotline-bling
Returns template details including image URL and text box positions.
Search templates
curl "https://justmeme.wtf/api/v1/templates/search?q=brain"
Trending memes
curl https://justmeme.wtf/api/v1/trending
AI meme generation
curl -X POST https://justmeme.wtf/api/v1/ai-generate -H "Content-Type: application/json" -d '{"prompt":"a cat coding"}'
Full API docs: justmeme.wtf/api-docs
Architecture Decisions
Why Cloudflare Workers?
I wanted zero cold starts and global edge deployment without managing servers. Workers spin up in less than 1ms and run in 300+ locations. For an image API that needs to be fast, this matters.
Why D1 over KV?
KV is great for simple key-value lookups, but I needed to query templates by category, search by name, and paginate results. D1 gives me SQL for free.
Image generation without Node Canvas
The tricky part was rendering text on images without node-canvas (which doesn't work in Workers). I used the built-in Canvas API available in Cloudflare Workers with the Browser Rendering binding. For simpler cases, I pre-compute text positions and overlay them on the fly.
SEO: Making Memes Indexable
Each of the 2,300+ templates has its own page at /meme/{slug} with:
- Unique title and meta description (not just the template name)
- Schema.org structured data
- OG image that's the actual meme template
- How-to content for each template
- Related templates for internal linking
The sitemap splits across multiple files to stay under the 50MB limit.
What I'd Do Differently
Start with fewer templates. I loaded 2,300 on day one. Google flagged a lot as "discovered but not indexed" because the pages looked too similar. Starting with 200 high-quality pages and growing would have been smarter.
Add user-generated content earlier. Google values pages that change. A comment section or "trending memes made with this template" would help.
Build the API first. The website gets traffic, but the API is what developers actually link to. I should have launched the API on its own and marketed it to dev communities.
Try It
- Website: justmeme.wtf
- GitHub: JustMeme-wtf/justmeme-api
- API docs: justmeme.wtf/api-docs
- Make a meme in 10 seconds: justmeme.wtf
The whole thing is a Cloudflare Worker. If you're building something that needs meme generation, the API is free. Use it.
Top comments (0)