Search for "QR code stopped working" and you'll find the same story over and over. A café or a shop prints a few hundred table cards with a QR code from a "free" generator. Weeks later, customers scan them and land on a page asking the owner to upgrade to a paid plan.
The generator never made a QR code for the menu. It made a QR code for its own short link, which pointed to the menu until the trial ended. I build Fizzdoc, a set of free tools that run entirely in the browser. When I added a QR generator, I wanted a QR generator that:
- makes static codes only: the link, Wi-Fi password or UPI ID is written into the code itself, so nothing can switch it off later;
- never uploads anything, logos included;
- doesn't look like a 2009 barcode;
- refuses to let you download a code it can't read back.
The fourth one turned out to be the interesting part.
Drawing the code yourself
The encoding itself is a solved problem. I used uqr, a tiny zero-dependency library that turns text into a grid of true/false modules. Everything visual is mine: one function turns that grid into an SVG, and the preview and every download (PNG, JPG, WebP, SVG, PDF) come from that same SVG.
The nicest trick is the "rounded" style. If you round every module, joined modules look like a chain of beads. So a corner only rounds when both of its neighbours are empty:
const up = dark(x, y - 1);
const down = dark(x, y + 1);
const left = dark(x - 1, y);
const right = dark(x + 1, y);
// top-left, top-right, bottom-right, bottom-left
const [tl, tr, br, bl] = [!up && !left, !up && !right, !down && !right, !down && !left]
.map((free, i) => (free && allowed[i] ? r : 0));
Lines of modules stay solid bars with soft ends, and lone modules become pills or circles. "Classy" is the same code with only two corners allowed. Five dot styles, three corner-frame shapes and three corner-centre shapes come out of about 80 lines. The whole generator, encoder included, is 11 KB compressed.
A few details that matter more than they look:
- Logos force error correction H. A logo hides the modules under it. Level H lets a phone rebuild up to 30% of the code, so the moment you add a logo, the setting switches to H and locks.
-
Wi-Fi escaping. The
WIFI:T:WPA;S:name;P:password;;format breaks if your network is calledHome;Net. Semicolons, commas, colons, quotes and backslashes all need a backslash in front. -
UPI. Every UPI app in India (Google Pay, PhonePe, Paytm, BHIM) reads the same NPCI link:
upi://pay?pa=shop@okicici&pn=Ram%20Stores&am=250&cu=INR. That one line is the whole "UPI QR generator" feature.
The self-check
Here's the problem with styled QR codes: it's very easy to make a beautiful one that phones can't read. Light dots on a dark background, a big logo, low contrast, a gradient that fades into the background colour.
Most generators warn you about contrast, at best. I wanted proof. So after every change (debounced by 400 ms) the page renders the code to a 600 px PNG and reads it back with ZXing, compiled to WebAssembly:
const { readCodes } = await import('../engine/scan');
const found = await readCodes(await raster(code, 600, 'image/png', true));
const ok = found.some((f) => f.text === text);
check.textContent = t(ok ? 'qr.scanOk' : 'qr.scanBad');
You see either "✓ Checked: this code scans" or a warning telling you what to try.
The ZXing WebAssembly file is 947 KB (413 KB compressed), so it only loads when the check first runs. It's served from fizzdoc.com itself, not a CDN, so it works offline too.
The test decoder that was lying to me
Every template gets a test in CI: the test downloads the PNG and decodes it. My first version used jsQR, a popular pure-JavaScript decoder.
The "Dots" template failed. Every time, at every size.
I spent a while staring at my SVG path for round dots, sure I'd broken the arcs. I hadn't. jsQR just doesn't cope well with codes made of separate round dots. ZXing, the decoder many phone scanner apps are built on, read the same image straight away.
The lesson: test with the decoder your users have. So I switched the tests to ZXing, running in Node with the same WebAssembly file. Dots passed. A test that fails for the wrong reason is worse than no test: I almost "fixed" a working feature to please it.
Now every template, a logo, a built-in icon and a background picture are each downloaded and decoded in CI. If a future change breaks scanning for any style, the build goes red.
The scanner, and why it never opens links by itself
Once ZXing was in the app, a scanner was a small step: camera, photo, or a pasted screenshot (handy when someone sends you a QR code on WhatsApp and you're on the same phone). It reads QR codes plus barcodes (EAN-13, UPC, Code 128, Data Matrix, PDF417 and more), several per picture.
QR codes are a popular way to hide a bad link, so the scanner never opens anything by itself. It shows the full text first, plus warnings that are checked on the device:
if (url.protocol === 'http:') out.push(t('scan.warnHttp'));
if (url.hostname.split('.').some((part) => part.startsWith('xn--'))) out.push(t('scan.warnLookalike'));
if (/^\d+\.\d+\.\d+\.\d+$|^\[/.test(url.hostname)) out.push(t('scan.warnIp'));
if (url.username) out.push(t('scan.warnAt', { host: url.hostname }));
The @ one is my favourite. https://paytm.com@203.0.113.9/login looks like Paytm, but everything before the @ is a username. The real host is the bare IP address after it. The scanner says so in plain words.
There's no "safe browsing" lookup, on purpose. That would mean sending every scanned link to someone's server, which is exactly what Fizzdoc doesn't do.
The bug I shipped anyway
All of that, every template tested, and the first thing I saw on my own phone after release was broken. The preview panel stayed stuck to the top of the screen and covered the form.
I'd written the phone rule (position: static) above the desktop rule (position: sticky) in the CSS file. Same specificity, so the later rule wins, and the media query did nothing. My phone check had only tested for sideways scrolling.
The fix was moving eight lines to the bottom of the file. The test that now guards it asserts the panel is static and sits entirely above the form at 390 px wide. Checking "it fits the screen" is not the same as checking "it doesn't overlap".
What I didn't build
No scan statistics, and no "edit the link after printing". Both need a server that every scan passes through, and that server sees who scans your code. It's also the exact mechanism behind those expired table cards. If I ever add short links, they'll be opt-in and off by default.
Try it
- QR Code Generator: fizzdoc.com/qr-code-generator (with pages for UPI, Wi-Fi, WhatsApp and contact cards)
- QR & Barcode Scanner: fizzdoc.com/qr-code-scanner
- Code: github.com/kingrishabdugar/fizzdoc, Apache-2.0. The engine is
src/engine/qr.ts; the tests aretests/qr.e2e.ts.
It's free, in 17 languages, and the code on the cover of this post was made with it. Point your camera at it.
If you've been burned by a QR code that "expired", I'd like to hear about it in the comments.


Top comments (0)