Free QR Code API for Developers
Generate QR codes via REST in milliseconds. Free, no API key. Returns SVG (default) or GIF for any text, URL, WiFi, vCard, mailto, sms, or geo URI. Edge-cached for fast embeds.
https://u2l.ai/api/tools/qr?data=https%3A%2F%2Fu2l.ai
curl "https://u2l.ai/api/tools/qr?data=https%3A%2F%2Fu2l.ai" -o qr.svg
<img src="https://u2l.ai/api/tools/qr?data=https%3A%2F%2Fu2l.ai" alt="QR code" width="300" height="300" />
This preview is the actual API response. Right-click to save the SVG / GIF.
Quick Answer
A QR code API exposes QR generation as a single HTTP endpoint. Hit GET /api/tools/qr?data=hello with the string you want to encode and get a scannable image back. The U2L QR Code API runs on Cloudflare Workers, returns SVG or GIF in milliseconds, supports any encoded payload (URL, text, WiFi, vCard, mailto, sms, geo), and is free with no key for normal use.
Quick Facts
- GET /api/tools/qr?data=YOUR_DATA returns a scannable QR image. SVG by default; pass format=gif for raster.
- Configurable size (64-2048 px), margin (0-16 modules), and error-correction level (L, M, Q, H).
- No auth, no API key, no rate limit beyond Cloudflare's standard Worker limits. Polite use is unmetered.
- Pure-JS encoder running at the edge - response time is typically 5-20ms after cold start.
- CORS enabled (Access-Control-Allow-Origin: *) so you can embed the API URL directly in <img> or fetch from any browser app.
- Edge-cached for 24 hours per unique URL. Repeat requests for the same data return instantly.
- Supports any QR-encodable payload: URLs, text, WiFi (WIFI:T:WPA;...;), vCard, mailto:, sms:, tel:, geo: URIs.
How to use the QR Code API
Three steps. Build the URL, fetch, embed.
- 1
Build the API URL
https://u2l.ai/api/tools/qr?data=URL_ENCODED_STRING. Optional: &format=svg|gif, &size=300, &margin=4, &ecl=M. Always URL-encode the `data` value so special characters survive.
- 2
Fetch or embed
Drop the URL into an <img src> for direct embedding, or fetch from JavaScript / curl / your backend. The response is image/svg+xml (default) or image/gif.
- 3
Cache and reuse
Each unique URL is edge-cached for 24 hours. Use stable parameters across repeat requests so cache hits maximize and your QRs render in milliseconds.
What is a Free QR Code API?
Free QR Code API is an HTTP endpoint that returns a scannable QR code image for any encoded string. Instead of pulling a QR library into your app and managing canvas dependencies, browser quirks, or server-side rendering, you just hit the API URL with the data you want encoded and get back a ready-to-display image. Perfect for transactional emails, dynamic web apps, marketing landing pages, and CMS-driven content where QRs need to be generated on demand.
QR generation has historically been a frontend concern - libraries like qrcode-styling or qr.js render in the user's browser. That works for static interactive tools, but breaks down for several real workflows: server-rendered email templates, PDF generation, image CDN integration, and headless CMS content. For any of those, you need a server-side QR generator. Running one on your own infra means picking a library, dealing with canvas dependencies, and managing scale.
The U2L QR Code API solves this. One stable URL, infinite QR codes. Run on Cloudflare Workers' edge network, so the QR renders within 30ms of the nearest CF region (most of North America, Europe, and Asia have a sub-50ms edge). No library to install, no canvas to polyfill, no rate limit to manage at small scale. Free for production use with reasonable polite request volumes.
The API supports both SVG (vector, infinite scaling, default) and GIF (raster, 1-bit, fits anywhere PNG fits). For most use cases SVG is the right choice - it scales to any print size, looks crisp on Retina displays, and embeds cleanly in HTML emails. GIF is there for legacy systems that can't render SVG (some printer drivers, some old email clients).
How does a Free QR Code API work?
When your app makes a GET request to /api/tools/qr?data=hello, Cloudflare routes the request to the nearest edge Worker. The Worker validates the parameters (data length under 2KB, size in 64-2048 range, valid ECL), then runs the qrcode-generator pure-JS encoder to produce the QR matrix.
The matrix is a 2D boolean array - one cell per QR module. The Worker iterates the matrix and emits an SVG path string consisting of M/h/v/z commands (one rectangle per dark module). The full SVG is wrapped with a viewBox so it scales infinitely and a white background rect so the QR is readable on any colored container.
For format=gif, the Worker uses qrcode-generator's built-in createDataURL which produces a base64 GIF. The Worker decodes the base64 and returns the raw GIF bytes with Content-Type: image/gif. GIF is 1-bit black/white, identical encoding to PNG-suitable for printing and embedding.
Responses are cached at the Cloudflare edge with public Cache-Control: max-age=86400 (24 hours). Identical request URLs return cached responses instantly without re-rendering. To invalidate cache, include a versioning param (?v=N) or use unique data per request.
Use Cases
How marketers, businesses, and developers use free qr code api.
Transactional email QR codes
Order confirmation emails embedding a QR for the order tracking URL. <img src="https://u2l.ai/api/tools/qr?data=..."> renders in every email client.
Server-rendered PDFs
Generating PDFs server-side (invoices, tickets, certificates) that include a QR. Hit the API, embed the SVG response inline. Works in Puppeteer, wkhtmltopdf, and serverless PDF generators.
Headless CMS image fields
Sanity, Contentful, or Strapi content with a QR field. Editors enter text; the API URL auto-generates a QR. No image hosting needed.
Dynamic ticket QRs (concert, conference)
Per-ticket unique QR encoding the ticket ID. Generated at request time so tickets can't be pre-computed and shared. Cached at the edge once seen.
Sticker / packaging printing automation
Daily script generates batch QRs for outbound packages. CSV in, SVG files out. Drop into your label printer's hot folder.
API for browser-based tools
Building a low-touch QR tool of your own? Skip writing the encoder; hit our API. CORS-enabled so direct fetch from browser works.
Static site generator builds
Astro, Next.js SSG, or Hugo sites generating QR codes at build time for inclusion in static HTML. Hit the API once per build, cache the SVG locally.
Slack / Discord bot integrations
Bots that respond to slash commands with QRs. /qr https://example.com returns a u2l.ai/api/tools/qr URL the bot pastes inline.
Marketing landing-page QRs
Landing pages with dynamic QR (per-campaign, per-source). Build the API URL with UTM data; the QR auto-encodes the destination.
Restaurant menu reorder buttons
Each menu item has a QR linking to a 'reorder this' URL with the item ID. Generated per-item via API; cached so repeat scans hit edge cache.
Free QR Code API vs Alternatives
Side-by-side feature and pricing comparison with the top alternatives.
| Feature | U2L | QR Server (qrserver.com) | GoQR.me | QRCode Monkey API |
|---|---|---|---|---|
| Free tier without signup | Limited | |||
| SVG output (vector) | Paid | |||
| Edge-cached responses | 24h | Unknown | Unknown | |
| CORS enabled | Limited | |||
| Configurable error correction (L/M/Q/H) | ||||
| Customizable margin / quiet zone | ||||
| Cloudflare edge latency (sub-50ms) | ||||
| Logo embed in QR | Soon | Limited | Paid |
Free QR Code API vs QR Server API (qrserver.com)
qrserver.com is a long-running free QR API that's been around since the early 2010s. Reliable, simple, and free - the standard answer for 'free QR API'.
U2L's API is functionally similar at the small-scale tier, with the addition of Cloudflare edge caching (so repeat embeds in transactional emails return instantly), CORS enabled, and SVG output as the default. For a fresh project starting today, U2L is the modern choice; for legacy projects already wired to qrserver.com, no need to migrate.
Free QR Code API vs Self-hosted with qrcode-generator
Running your own QR endpoint with the qrcode-generator npm library takes 30 lines of code. Total control, zero external dependency, fully on your infra.
U2L's hosted API saves you that setup, plus gives you Cloudflare's edge network for global low-latency rendering. For high-volume internal use, self-host. For shared / customer-facing QR generation, U2L's free tier is enough for most projects.
Best Practices
URL-encode the data parameter
Always wrap the data value in encodeURIComponent (JS) or url-quote (Python). Special chars like &, =, # in the data will break the URL otherwise.
Use SVG by default
SVG scales to any size, looks crisp on Retina, and embeds cleanly in HTML email. Use GIF only when the receiving system can't render SVG (rare; most printer drivers handle SVG fine).
Pick the right error-correction level
M (default, ~15% recovery) is fine for most cases. L (7%) gives smaller QRs but less damage tolerance. H (30%) is for QRs that will be partially obscured by a logo or printed on rough surfaces.
Don't cache-bust with random parameters
Each unique URL generates a fresh response. If you append random ?t=NOW, every request re-renders. Use stable URLs to leverage the 24h edge cache.
Set size based on intended scan distance
Print 2cm QR (size=300) for desk-distance scans (30cm). Scale up linearly: 5cm for 1m, 10cm for 2m. Bigger isn't always better - too-large QRs need larger viewport to scan in one frame.
Test on iOS Camera and Android Camera
Most modern phones scan via the camera app directly. Test the QR with both before deploying. Lower-quality scanners are now rare; if it works on iOS Camera, it works on 99% of devices.
Use the API for dynamic content, embed static for fixed
Dynamic per-user QRs - hit the API every render. Fixed company-wide QRs (a single product page link) - generate once, save the SVG, serve from your own CDN.
Keep data under 1KB for reliable scans
QR matrix grows denser with longer data. Strings under 1KB encode comfortably. For longer payloads, shorten the URL first via U2L Link Shortener and encode the shortened URL.
Common Mistakes to Avoid
Forgetting to URL-encode the data
https://u2l.ai/api/tools/qr?data=Hello&world=foo - the API sees data=Hello and ignores the rest. Always encodeURIComponent your data value.
Stuffing too much into one QR
QRs over 2KB get rejected. QRs over ~500 chars become so dense they only scan reliably at very large print sizes. For long data, use a u2l.ai short link first.
Using format=gif for print
GIF is raster - locked to the resolution at which it was rendered. For print, use SVG and let the printing software scale. GIF is fine for screen embedding only.
Hardcoding size beyond what's needed
size=2048 generates a huge SVG (still fast, but more bytes). For email embedding or 200x200 display, size=300 is plenty. Scale up only when print dpi requires it.
Treating the API as a sustained-load backend
Cloudflare Workers have polite-use limits. Don't loop 1000 QR generations from one IP per second. For sustained high-volume, sign up to U2L Pro or self-host.
Setting margin=0
QR scanners need a 4-module quiet zone (white border) to isolate the pattern. margin=0 produces a QR that doesn't scan reliably. Default is 4; don't go below 2.
Embedding sensitive data directly
QRs are public. Anyone with the API URL or scanned image can read the data. For sensitive content (auth tokens, signed URLs), embed a short-lived signed URL, not the secret directly.
Technical Specifications
| Endpoint | GET https://u2l.ai/api/tools/qr |
| Required params | data (string, max 2048 chars, URL-encoded) |
| Optional params | format (svg|gif, default svg), size (64-2048 px, default 300), margin (0-16 modules, default 4), ecl (L|M|Q|H, default M) |
| Output Content-Type | image/svg+xml or image/gif |
| Encoding | Pure-JS qrcode-generator (RFC ISO/IEC 18004) |
| Cache headers | public, max-age=86400, s-maxage=86400, immutable |
| CORS | Access-Control-Allow-Origin: * (browser fetch enabled) |
| Auth | None required for normal use |
| Latency | Sub-30ms median from Cloudflare edge regions |
| Auto type-number | Yes - the encoder picks the smallest QR size that fits the data + ECL |
Industry-Specific Use Cases
Email and transactional messaging
Order confirmations, receipts, password-reset emails with embedded QR. Edge cache means repeat embeds (across many emails to many recipients) hit cache.
Ticketing and event tech
Per-ticket unique QRs at scale. The API handles concurrent generation; Cloudflare Workers scale automatically with traffic spikes.
SaaS and B2B web apps
QR display in dashboards, settings pages, account-sharing flows. Server-rendered PDFs and email templates with embedded QRs.
Ecommerce and order management
Per-package QRs on shipping labels, per-product QRs on packaging linking to support / reorder pages.
Marketing and growth automation
Per-campaign QRs on landing pages, A/B testing different QRs per audience segment, automated newsletter QR rotation.
Static site generators and JAMstack
Build-time QR generation for static HTML output. Astro, Next.js SSG, Hugo, Eleventy - all can hit the API at build time and embed the response inline.
Frequently Asked Questions
Is the API really free?
Do I need an API key?
What's the maximum data length?
Can I get PNG instead of GIF or SVG?
How is this different from qrserver.com?
Can I embed the API URL in an <img> tag?
Is CORS enabled?
Can I encode WiFi credentials in the QR?
Does it support vCard QRs?
How long are responses cached?
What error-correction level should I use?
Can I customize colors, add a logo, or use a custom shape?
What happens if my data is too long for any QR size?
Can I use this for commercial projects?
What's the rate limit?
Does the API support CORS preflight (OPTIONS)?
Will the API URL stay stable?
Can I track scans with this API?
Related Free Tools
Whois Lookup
Look up registrar, owner, creation date, expiry, and DNS for any domain. Free Whois data, no API key.
DNS / CNAME Checker
Look up A, AAAA, CNAME, MX, TXT, NS records for any domain. Verify global DNS propagation in seconds.
SSL Certificate Checker
Inspect any SSL certificate: validity, issuer, chain, expiry, and protocol. Spot issues before users do.
HTTP Header Inspector
Inspect HTTP request and response headers for any URL. Cache, security, CORS, and server details.
URL Shortener Speed Test
Compare redirect response times across 10+ URL shorteners. Real measurements in your browser.
Deep Link Tester
Test iOS Universal Links and Android App Links. Validate scheme, host, and fallback behavior.
Key Terms
- QR Code
- A 2D barcode invented by DENSO WAVE in 1994. Standardized in ISO/IEC 18004. The U2L API uses the open standard; 'QR Code' is a registered trademark of DENSO WAVE.
- Error correction level
- How much of the QR pattern can be damaged or obscured and still scan. L = 7%, M = 15%, Q = 25%, H = 30%. Higher levels mean denser pattern; M is the standard balance.
- Module
- A single black or white square in the QR pattern. QR sizes are described as 'NxN modules' (21x21 for type 1, 177x177 for type 40).
- Quiet zone
- The required white border around a QR (4 modules wide minimum). Without a quiet zone, scanners can't isolate the QR pattern from surrounding artwork. Default margin in the API is 4.
- Type number
- QR pattern size, 1-40. Type 1 = 21x21 modules, type 40 = 177x177. The API auto-selects the smallest type that fits your data + ECL.
- DoH (DNS-over-HTTPS)
- Not directly used by the QR API, but related: Cloudflare's DoH backbone is what makes Workers' edge DNS lookups fast. The QR API itself doesn't make outbound DNS queries.
Want logo-embedded QRs and per-scan analytics?
Sign up free for the QR Code API Pro tier - logo overlay, custom colors, scan tracking, and higher rate limits. No credit card; takes 30 seconds.
Sign up free