QR Code Image API
A free public GET endpoint that returns a QR code image — drop the URL straight into <img>, Markdown, email, or any HTTP client.
Live URL Builder
Tweak the parameters below — the URL and the preview update in real time.
Endpoint
Returns the raw image bytes. Responses are cacheable for one year via Cache-Control: public, max-age=31536000, immutable. CORS is wide-open (Access-Control-Allow-Origin: *).
Query parameters
| Name | Type | Default | Description |
|---|---|---|---|
| data required | string | — | The text or URL to encode. Up to 2048 characters. |
| size | integer | 300 | Output edge length in pixels. Clamped to [50, 1000]. |
| format | enum | png | png or svg. |
| ec | enum | M | Error correction level: L ~7%, M ~15%, Q ~25%, H ~30%. |
| margin | integer | 1 | Quiet-zone width in QR modules (not pixels). Clamped to [0, 10]. |
| color | hex6 | 000000 | Foreground color, 6-character hex (with or without leading #; URL-encode as %23). |
| bgcolor | hex6 | ffffff | Background color, same format as color. |
Invalid values return 400 Bad Request with a plain-text reason.
Examples
<img src="https://qrcode.fun/api/qr-image?data=https%3A%2F%2Fqrcode.fun&size=240" alt="QR" />curl -o qr.png "https://qrcode.fun/api/qr-image?data=hello&size=400"curl -o qr.svg "https://qrcode.fun/api/qr-image?data=hello&format=svg"const res = await fetch(
'/api/qr-image?data=' + encodeURIComponent('hello world')
)
const blob = await res.blob()
imgEl.src = URL.createObjectURL(blob)import requests
url = 'https://qrcode.fun/api/qr-image'
r = requests.get(url, params={'data': 'hello', 'size': 400})
open('qr.png', 'wb').write(r.content)Where it shines
Email signatures
Drop a URL into your signature template — every recipient sees a fresh QR without any attachment.
README badges
Embed the same way you embed shields.io badges. The image is cached for a year.
Dynamic UIs
Bind the URL to component state — when the data changes, the browser refetches automatically.
No-build pages
Static HTML, plain CMS posts, or any platform that lets you paste an image URL.
FAQ
Is the API free?
Yes. There's no auth, no API key, and no rate limit beyond standard CDN protection. Be considerate; the endpoint is shared.
How long are images cached?
One year (immutable). Each unique URL is treated as canonical, so changing any parameter produces a new cache entry. Identical URLs return cached responses immediately.
Why is `margin` measured in modules instead of pixels?
A QR's "quiet zone" is defined by the spec in module units (the small squares that make up the code), not pixels. This keeps the safe whitespace consistent regardless of your chosen `size`.
Why no logo, dot styles, or gradients?
This endpoint is intentionally minimal so it stays fast and cacheable. For styled output (logos, custom dot/eye shapes, gradients), use the POST /qrcode-api endpoint.
What happens when I encode too much data?
If your text exceeds the QR version capacity at the requested error-correction level, you'll get a 400 with the underlying reason. Try `ec=L` (more capacity) or shorten the data.
Can I use this from browser JavaScript?
Yes — `Access-Control-Allow-Origin: *` is set on every response, so `fetch()` and `<img>` work cross-origin without any setup.