Free Tool

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.

14 / 2048 chars
API URL
https://u2l.ai/api/tools/qr?data=https%3A%2F%2Fu2l.ai
curl
curl "https://u2l.ai/api/tools/qr?data=https%3A%2F%2Fu2l.ai" -o qr.svg
HTML embed
<img src="https://u2l.ai/api/tools/qr?data=https%3A%2F%2Fu2l.ai" alt="QR code" width="300" height="300" />
Live API response
Live QR API preview

This preview is the actual API response. Right-click to save the SVG / GIF.

No signup required
Free forever
GDPR compliant
Powered by U2L

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. 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. 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. 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.

FeatureU2LQR Server (qrserver.com)GoQR.meQRCode Monkey API
Free tier without signupLimited
SVG output (vector)Paid
Edge-cached responses24hUnknownUnknown
CORS enabledLimited
Configurable error correction (L/M/Q/H)
Customizable margin / quiet zone
Cloudflare edge latency (sub-50ms)
Logo embed in QRSoonLimitedPaid

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

EndpointGET https://u2l.ai/api/tools/qr
Required paramsdata (string, max 2048 chars, URL-encoded)
Optional paramsformat (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-Typeimage/svg+xml or image/gif
EncodingPure-JS qrcode-generator (RFC ISO/IEC 18004)
Cache headerspublic, max-age=86400, s-maxage=86400, immutable
CORSAccess-Control-Allow-Origin: * (browser fetch enabled)
AuthNone required for normal use
LatencySub-30ms median from Cloudflare edge regions
Auto type-numberYes - 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?

Yes for normal use. No API key required. Cloudflare Workers' standard limits apply (which are generous for the typical embed-in-email or embed-in-CMS use case). For sustained high-volume, sign up to U2L Pro or self-host.

Do I need an API key?

No. Hit the URL directly with your `data` parameter and the QR comes back. No registration, no key, no usage caps for polite requests.

What's the maximum data length?

2048 characters. Anything longer gets rejected with a 400 error. For long URLs, shorten via U2L Link Shortener first and encode the shortened URL (cleaner result, smaller QR).

Can I get PNG instead of GIF or SVG?

Currently only SVG (default) and GIF (set format=gif). GIF is 1-bit and works wherever PNG works for QR codes. True PNG output requires a heavier encoder; on the roadmap if there's demand. For now, SVG covers most use cases.

How is this different from qrserver.com?

Functionally similar at the basic tier. U2L is on Cloudflare's edge (faster from most regions), defaults to SVG (better for modern web), and has 24h edge cache (faster repeat embeds in transactional email). For new projects, U2L is the modern choice.

Can I embed the API URL in an <img> tag?

Yes. <img src="https://u2l.ai/api/tools/qr?data=hello"> works directly. The Content-Type is set correctly (image/svg+xml or image/gif), so browsers render the response as an image.

Is CORS enabled?

Yes. Access-Control-Allow-Origin is set to '*'. You can fetch the API URL from any browser-side JS app to inspect the response (e.g. show a preview before downloading).

Can I encode WiFi credentials in the QR?

Yes. Pass the WIFI: URI as data: data=WIFI:T:WPA;S:MyNetwork;P:password123;;. URL-encode the whole string. The same syntax works for any QR-encodable URI (mailto:, sms:, tel:, geo:).

Does it support vCard QRs?

Yes. Pass a properly-formatted BEGIN:VCARD ... END:VCARD string as data (URL-encoded, including newlines as %0A). For a UI builder, see /tools/vcard-qr-code-generator.

How long are responses cached?

24 hours at the Cloudflare edge per unique URL. Identical request URLs return cached responses instantly (sub-1ms within Cloudflare). Append a version param (?v=2) to bust cache when the underlying data changes.

What error-correction level should I use?

M (default, 15% recovery) is fine for most cases. Use L for smallest QRs (7% recovery, brittle). Use H for QRs that will be partially obscured (logo overlay, scuffed prints, 30% recovery).

Can I customize colors, add a logo, or use a custom shape?

Currently the API outputs monochrome black-on-white. Color, logo, and custom shape support is on the roadmap. For now, use the browser-only QR generators at /tools/qr-code-generator (or any of the specific QR tools) for styled output.

What happens if my data is too long for any QR size?

The API returns a 400 error. The qrcode-generator library auto-selects the smallest QR type that fits; if even type 40 (the largest) can't fit your data, you've exceeded the QR specification's hard limit. Shorten first.

Can I use this for commercial projects?

Yes. The U2L API has no commercial restriction. The QR code specification itself is patent-free and trademark-only (DENSO WAVE owns 'QR Code' as a trademark but the format is open). Use commercially without attribution required.

What's the rate limit?

Cloudflare Workers' default polite-use limits apply (effectively a few hundred requests per second per IP without special setup). For sustained higher volumes, sign up to U2L Pro or self-host with the qrcode-generator npm library.

Does the API support CORS preflight (OPTIONS)?

Currently the API responds to GET only. Pre-flight isn't needed for simple GET requests with image responses. If you have a use case requiring OPTIONS pre-flight, file a feature request.

Will the API URL stay stable?

Yes. /api/tools/qr is committed to the U2L public surface. Param names (data, format, size, margin, ecl) won't change. New params may be added (color, logo) but won't break existing requests.

Can I track scans with this API?

The API itself doesn't track scans (the QR is rendered statically). To track scans, encode a u2l.ai short link in the QR. The short link tracks every redirect; the QR is a deeplink to the tracking URL.

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