Overview
The QR Gen API lets you generate QR codes with a single HTTP request. It is completely free, requires no authentication or API keys, and supports CORS for browser-based applications. Responses are edge-cached for fast delivery worldwide.
- Free to use — no signup, no API key, no rate limit headers
- CORS enabled — call it directly from the browser
- Multiple formats — PNG, SVG, or raw JSON module matrix
- Edge cached — identical requests are served from cache at the edge
- GET and POST — use query parameters or a JSON body
Base URL
https://qrgenapp.com/api/qrParameters
All parameters shown here work with both GET (query string) and POST (JSON body) requests unless noted otherwise.
| Parameter | Type | Default | Description |
|---|---|---|---|
data | string | — | Required. The content to encode in the QR code. Can be a URL, plain text, WiFi config, vCard, or any string. |
format | string | png | Output format. One of png, svg, or json. |
size | integer | 256 | Image dimensions in pixels. Range: 32 to 2048. For PNG output, this is the exact width and height. For SVG, this sets the viewBox. |
color | string | 000000 | Foreground color as a 6-digit hex code (without #). |
bg | string | ffffff | Background color as a 6-digit hex code (without #). |
ec | string | M | Error correction level. One of L (7%), M (15%), Q (25%), or H (30%). |
margin | integer | 4 | Quiet zone width in modules. Range: 0 to 10. |
logo | string | — | Public URL of a logo image to overlay in the center of the QR code. Supported on png and svg output. Max 2MB. Error correction is automatically set to H when a logo is used (unless you explicitly set ec). |
logoData | string | — | Inline logo data for POST requests. Accepts a base64 data URI such as data:image/png;base64,... or a raw base64 string. Use this when you do not want the API to fetch the logo from a public URL. |
logoMime | string | image/png | MIME type for raw base64 logoData. Ignored when logoData is already a data URI. Supported values: image/png, image/jpeg, image/webp, and image/svg+xml. |
logoSize | number | 0.25 | Logo size as a fraction of the QR code dimensions. Range: 0.1 to 0.4. A value of 0.25 means the logo covers 25% of the QR code width and height. |
logoMargin | integer | 0 | Padding around the logo in pixels. Range: 0 to 20. Useful when you want a white buffer between the logo and nearby QR modules. |
GET Request
The simplest way to generate a QR code. Pass parameters as query string values.
Basic Example
curl "https://qrgenapp.com/api/qr?data=https://example.com" -o qr.pngWith Options
curl "https://qrgenapp.com/api/qr?data=https://example.com&format=svg&size=512&color=1a1a1a&bg=f5f5f5&ec=H&margin=2" -o qr.svgJSON Output
curl "https://qrgenapp.com/api/qr?data=hello&format=json"format=json returns only the raw module matrix. Logo overlay parameters such as logo, logoSize, and logoMargin are ignored in JSON mode.
POST Request
For more complex data or when you need to avoid URL encoding issues, use a POST request with a JSON body.
curl
curl -X POST https://qrgenapp.com/api/qr \
-H "Content-Type: application/json" \
-d '{
"data": "https://example.com",
"format": "png",
"size": 512,
"color": "000000",
"bg": "ffffff",
"ec": "H",
"margin": 4
}' -o qr.pngJavaScript (fetch)
const response = await fetch("https://qrgenapp.com/api/qr", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
data: "https://example.com",
format: "png",
size: 512,
ec: "H"
})
});
const blob = await response.blob();
const url = URL.createObjectURL(blob);
// Display in an img element
document.getElementById("qr").src = url;Response Formats
PNG (default)
Returns a PNG image. The response Content-Type header is image/png.
HTTP/1.1 200 OK
Content-Type: image/png
Cache-Control: public, max-age=86400
Content-Length: 1842SVG
Returns an SVG document. The response Content-Type header is image/svg+xml. SVG output is resolution-independent and typically smaller in file size.
HTTP/1.1 200 OK
Content-Type: image/svg+xml
Cache-Control: public, max-age=86400JSON
Returns the QR code as a JSON object with the module matrix. Useful for custom rendering in canvas, terminal output, or other creative applications.
HTTP/1.1 200 OK
Content-Type: application/json
{
"modules": [
[1, 1, 1, 1, 1, 1, 1, 0, 1, 0, ...],
[1, 0, 0, 0, 0, 0, 1, 0, 0, 1, ...],
...
],
"size": 29
}Each value in the modules array is 1 (dark/foreground) or 0 (light/background). The size field indicates the number of modules per side.
HTML Embed
The simplest integration is a plain <img> tag. Because the API returns images directly via GET, you can use it as an image source without any JavaScript.
<img
src="https://qrgenapp.com/api/qr?data=https://example.com&size=256"
alt="QR code for example.com"
width="256"
height="256"
>For Markdown documents, READMEs, and chat interfaces:
Logo Overlay
Add a logo to the center of your QR code by passing a logo URL. Error correction is automatically set to H for maximum scan reliability when a logo is present.
GET with Logo
curl "https://qrgenapp.com/api/qr?data=https://example.com&logo=https://example.com/logo.png&size=512" -o qr-with-logo.pngPOST with Logo
const res = await fetch("https://qrgenapp.com/api/qr", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
data: "https://example.com",
format: "svg",
size: 512,
logo: "https://example.com/logo.png",
logoSize: 0.3,
logoMargin: 8
})
});POST with Inline Logo Data
const res = await fetch("https://qrgenapp.com/api/qr", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
data: "https://example.com",
format: "png",
size: 512,
logoData: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",
logoSize: 0.25,
logoMargin: 6
})
});Notes
- Logo overlays are supported on the single QR endpoint
/api/qrfor PNG and SVG output. - JSON output does not embed a logo. It only returns the raw QR module matrix.
logoDatalets you send the logo inline in POST requests, so the API does not need to fetch a public URL.logoSizecontrols how much of the QR code the logo covers (0.1 = 10%, 0.4 = 40%). Default is 0.25 (25%).logoMarginadds spacing around the logo. This is useful for preserving scan reliability when the logo has a busy edge.- Whether you use
logoorlogoData, the final logo payload must be under 2MB. - The API fetches the logo, embeds it as a data URI, and renders it into the final image. QR modules behind the logo are removed in SVG output for clean rendering.
Batch Generation
Use POST /api/qr/batch to generate multiple QR codes in a single request. Shared options apply to all items unless overridden per item.
const res = await fetch("https://qrgenapp.com/api/qr/batch", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
options: {
format: "png",
size: 512,
dotStyle: "rounded",
color: "111111"
},
items: [
{ data: "https://example.com/a" },
{
data: "https://example.com/b",
logo: "https://example.com/logo.png",
logoSize: 0.22
},
{
data: "https://example.com/c",
format: "svg",
logoData: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
}
]
})
});The batch endpoint now supports the same styling options as the single QR endpoint, including logo overlays and PNG output.
format=svgreturns ansvgstring for each item.format=pngreturnspngBase64andmimeTypefor each item.format=jsonreturns the raw module matrix for each item.- Up to
50items are allowed per request.
Validation Endpoint
Use GET /api/qr/validate or POST /api/qr/validate to inspect a QR request before rendering it. /api/qr/inspect is available as an alias.
curl -X POST https://qrgenapp.com/api/qr/validate \
-H "Content-Type: application/json" \
-d '{
"data": "https://example.com",
"format": "png",
"color": "222222",
"bg": "ffffff",
"logoSize": 0.35,
"logoData": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
}'The response includes normalized options, QR density metadata, color contrast, and a list of warnings or errors such as low contrast, oversized logos, missing quiet zone, or unreachable logo assets.
Rate Limits & Caching
The API has generous rate limits suitable for most applications. Identical requests are cached at the edge, so repeated calls for the same QR code are served instantly from cache. There are no rate limit headers or quotas to manage. If you need extremely high volume (millions of requests per day), please reach out.
Error Responses
Errors are returned as JSON with an appropriate HTTP status code.
HTTP/1.1 400 Bad Request
Content-Type: application/json
{
"error": "Missing required parameter: data"
}| Status | Meaning |
|---|---|
400 | Bad request. Missing data parameter, invalid format, size out of range, invalid hex color, or margin out of range. |
413 | Payload too large. The data string exceeds the maximum encodable length for the selected error correction level. |
500 | Internal server error. Something unexpected went wrong. |
OG Image API
QR Gen also provides an Open Graph image generation endpoint, useful for generating social preview images dynamically.
GET https://qrgenapp.com/api/og?title=My+Page+Title&data=https://example.com&color=ff0000| Parameter | Description |
|---|---|
title | The title text rendered on the OG image. |
data | The data encoded in the QR code shown on the image. |
color | Accent color as a 6-digit hex code (without #). |
The response is a 1200x630 PNG image, suitable for <meta property="og:image"> tags. Use it to dynamically generate social cards that include a QR code.
<meta property="og:image" content="https://qrgenapp.com/api/og?title=My+App&data=https://myapp.com&color=3b82f6">Code Examples
JavaScript (Node.js / Browser)
// Generate a QR code and save it (Node.js)
import { writeFile } from "fs/promises";
const res = await fetch("https://qrgenapp.com/api/qr", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
data: "https://example.com",
format: "png",
size: 1024,
ec: "H"
})
});
if (!res.ok) {
const err = await res.json();
throw new Error(err.error);
}
const buffer = Buffer.from(await res.arrayBuffer());
await writeFile("qr.png", buffer);
console.log("Saved qr.png");Python
import requests
response = requests.get("https://qrgenapp.com/api/qr", params={
"data": "https://example.com",
"format": "png",
"size": 512,
"ec": "H"
})
response.raise_for_status()
with open("qr.png", "wb") as f:
f.write(response.content)
print("Saved qr.png")Using POST with a JSON body:
import requests
response = requests.post("https://qrgenapp.com/api/qr", json={
"data": "WIFI:T:WPA;S:MyNetwork;P:MyPassword;;",
"format": "svg",
"size": 512,
"color": "1a1a1a",
"ec": "Q"
})
response.raise_for_status()
with open("wifi-qr.svg", "w") as f:
f.write(response.text)
print("Saved wifi-qr.svg")curl
# Simple GET — saves a PNG
curl "https://qrgenapp.com/api/qr?data=https://example.com" -o qr.png
# SVG with custom colors
curl "https://qrgenapp.com/api/qr?data=https://example.com&format=svg&color=ff0000&bg=000000" -o qr.svg
# POST with JSON body
curl -X POST https://qrgenapp.com/api/qr \
-H "Content-Type: application/json" \
-d '{"data":"https://example.com","format":"png","size":1024}' \
-o qr.png
# Get the module matrix as JSON
curl "https://qrgenapp.com/api/qr?data=hello+world&format=json" | jq '.size'Go
package main
import (
"fmt"
"io"
"net/http"
"net/url"
"os"
)
func main() {
params := url.Values{}
params.Set("data", "https://example.com")
params.Set("format", "png")
params.Set("size", "512")
params.Set("ec", "H")
resp, err := http.Get("https://qrgenapp.com/api/qr?" + params.Encode())
if err != nil {
fmt.Fprintf(os.Stderr, "request failed: %v\n", err)
os.Exit(1)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
fmt.Fprintf(os.Stderr, "error %d: %s\n", resp.StatusCode, body)
os.Exit(1)
}
file, err := os.Create("qr.png")
if err != nil {
fmt.Fprintf(os.Stderr, "file create failed: %v\n", err)
os.Exit(1)
}
defer file.Close()
_, err = io.Copy(file, resp.Body)
if err != nil {
fmt.Fprintf(os.Stderr, "write failed: %v\n", err)
os.Exit(1)
}
fmt.Println("Saved qr.png")
}Try It Now
Generate a QR code in your browser with the visual editor, or start making API calls right away.
Open Editor