Menu

Our QR tool tops out at 2,331 characters, and past that it shows the error beside the previous code with the download buttons still lit
📰

Our QR tool tops out at 2,331 characters, and past that it shows the error beside the previous code with the download buttons still lit

DEV Community: react·Daniel Pertu·about 17 hours ago
#AwFl9XZz
#devtoreact#devto#dev#code#characters
Long article (1058 words) — no AI summary yet.
Reading 0:00
15s threshold

Our site has a free QR code generator at pub-trivia.app/tools/qr-code-generator . You paste a link, it draws a code, and you can download a PNG or an A4 sheet of four. It runs entirely in the browser with the qrcode package, so the link you type never leaves your machine.

I had measured how big the tool is. I had never asked how long a link it will take, what the code looks like at that length, or what the page does when it refuses. Those are three separate questions with three separate answers, and the third one is a bug.

The ceiling

The tool calls QRCode.toDataURL(url, { width: 512, margin: 2 }) and leaves error correction on the library default, level M. At level M the biggest code a QR can be is version 40, which holds 2,331 bytes. I found the limit by binary search on the real function: a URL of 2,331 ASCII characters encodes, and a URL of 2,332 throws.

Non-ASCII text hits it sooner, because the capacity is counted in bytes.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.