How QR Codes Work and How to Make One That Scans Every Time
What is inside a QR code, how error correction works, and the practical rules for size, contrast, content and printing.
What a QR code is
A QR (Quick Response) code is a two-dimensional barcode invented in Japan in 1994 to track car parts. Unlike a traditional barcode, which holds a short number in one direction, a QR code stores data in a grid of squares, in both directions, so it can hold a web address, a paragraph of text, contact details and more. A phone camera reads it in a fraction of a second, even at an angle.
What is inside the grid
The three large squares in the corners tell the scanner where the code is and how it is rotated. A smaller square pattern in larger codes corrects distortion if the code is printed on a curved surface. Thin alternating lines, called timing patterns, help the scanner count the rows and columns. The rest of the squares hold the message plus extra error-correction data.
Codes come in 40 sizes, called versions, from 21 × 21 modules up to 177 × 177. The longer your text, the bigger and denser the code. The largest version can hold roughly 7,000 digits, about 4,300 letters and numbers, or about 2,900 bytes of general text, but codes that dense are hard to scan, so keep your content short.
Error correction
QR codes use Reed–Solomon error correction, so part of the code can be dirty, damaged or covered and it still reads. There are four levels: L recovers about 7 percent of the data, M about 15 percent, Q about 25 percent and H about 30 percent. Higher levels make a denser code for the same content. For printed material that might get scuffed, a medium or higher level is a good trade. This is also why some codes carry a small logo in the middle: the logo covers part of the data, and error correction fills the gap, though it needs a high level and careful testing.
Rules for a code that scans
Contrast: dark modules on a light background are the safest. Inverted (light on dark) codes fail on many older scanners. Quiet zone: leave a blank border of at least four modules around the code. Size: print at least about 2 cm (0.8 in) square for close scanning, and larger when people scan from a distance; a rule of thumb is one tenth of the scanning distance. Surface: avoid glossy surfaces under spotlights, or curved bottles that distort the grid.
Always test with at least two phones, one old and one new, before printing hundreds of copies.
Choosing the content
For a web address, use the full https:// link and keep it short. Long addresses with tracking parameters make dense codes. If you control the page, a short, clean address makes a simpler code, and the Slug Generator can help you make a tidy path. If a link contains spaces or symbols in its query, encode those pieces with the URL Encoder / Decoder.
The code made by the QR Code Generator is static. The content is stored inside the picture, so it never expires and nothing records scans. The downside is that you cannot change where it points once printed, so make sure the destination page will be around for as long as the code is.
Safety when scanning
Treat a QR code like any link: check the address your phone shows before opening it. Criminals sometimes stick fake codes over real ones, such as on parking meters, to send people to fake payment pages. Be careful with codes that ask for passwords, payment details or software installs, and never scan a code that looks like it has been stuck over another.