A coupon generator turns a list of customers and codes into one image each. jsontoimg fills the discount, expiry date, and a unique code on named layers, draws that code as a QR or barcode, and returns a PNG for email or a PDF for print. It suits shops, restaurants, and apps running win-back or referral campaigns.
Layers that change per coupon
offer: the discount text, such as “20% off your next order”expires: a date you format before sending; the API does not localize datescode_text: the code printed in readable characterscode: a Code layer with formatqrcodeorcode128, carrying the same code
Brand, terms text, and layout stay in the template.
Render one coupon
{
"template": "<design-id>",
"format": "png",
"layers": {
"offer": { "text": "20% off your next order" },
"expires": { "text": "Valid until 31 Dec 2026" },
"code_text": { "text": "WELCOME-7K2Q9" },
"code": { "text": "WELCOME-7K2Q9" }
}
}
For a list of 1,000 customers, send twenty batches of 50 and key each job by customer id.
You issue and redeem the code
jsontoimg does not generate, store, or validate coupon codes. Create the codes in your own system, make them unguessable, and check them at redemption. A sequential code like SAVE1, SAVE2 lets anyone invent a valid one. Mark each code single-use and tied to the customer on your side.
Check what the scanner reads
If the coupon is scanned at a till, find out which code formats the point-of-sale hardware reads before you choose qrcode or code128. Print a test coupon and scan it. For emailed coupons, put the readable code next to the QR so a customer can type it in.
Delivery
Send the signed assetUrl in the email, or embed it in an <img> tag. The email hero images page covers sizing and alt text for images in email clients. Add alt text that states the offer and code, since some clients block images by default.
Related
FAQ
What is a coupon generator?
A tool that renders a coupon image or PDF per customer from a template and a list of codes. jsontoimg fills the offer, expiry, and a Code layer.
Does jsontoimg create the coupon codes?
No. Generate unguessable single-use codes in your own system and pass them in. jsontoimg only draws them as text and a QR or barcode.
Which format should the coupon code use?
QR works for phone scans. For a till scanner, check which formats the hardware reads, then choose qrcode or code128 and test one printed coupon.
How many coupons can I render in one request?
A batch holds 50 jobs. A list of 1,000 customers is twenty batches, keyed by customer id.