How QR codes work
A QR code is a grid of dark and light squares called modules. Some are fixed landmarks for the camera; the rest are your data plus spare bytes for repairing damage. Here is each part, live.
Finder patterns
Three big squares in the corners. Their 1:1:3:1:1 dark-light ratio looks the same from any angle, so a camera can find the code, work out its rotation and correct for tilt in one pass.
192 of 841 modules in this code.
Watch the grid grow: more recovery bytes need more modules, so the code steps up a version.
From text to squares, in four steps
- Pick an encoding mode. Digits-only content is packed 3 digits per 10 bits, upper-case alphanumerics 2 per 11 bits, and anything else goes byte by byte (UTF-8 here). That's why an all-caps URL can produce a slightly smaller code.
- Pick a version. Versions run from 1 (21×21 modules) to 40 (177×177). Each step adds 4 modules per side; the generator chooses the smallest that fits your data at the chosen error-correction level.
- Add error correction. The data is split into blocks and each gets Reed–Solomon codewords, the same family of maths used on CDs and in deep-space radio links. Level L can recover about 7% of codewords, M 15%, Q 25%, H 30%.
- Place and mask. Codewords are laid in a two-column zig-zag from the bottom-right corner, skipping the landmarks. Then one of eight mask patterns is XOR-ed over the data so there are no big solid patches or look-alike finder patterns, and the choice is written into the format bits.
Why it reads at an angle
The three finder squares have a 1:1:3:1:1 ratio of dark and light along any line through their centre, from any direction. A decoder scans for that ratio, finds three hits, and from their positions knows which way up the code is and how it's skewed. The missing fourth corner is the clue to orientation. Positions, not pixels, carry the meaning here, and the Moon's phases are a geometry story too: ahaboo walks through why, with narration.
Cover it and see what survives
Drag the sticker size and switch levels. Each change is decoded live by the ZXing library, the same kind of decoder a scanner app runs.
The percentages are codewords, not area. A sticker that also hits a finder pattern or the format bits can break a code long before the limit, and because damage lands unevenly on codewords the real cut-off moves around. That is why logos go in the middle and you should always test a printed code.
How to make a QR code that scans first time
- Open the QR code generator and choose the type: link, Wi-Fi, contact, email, SMS, WhatsApp or phone.
- Use the shortest link you can. Every character adds modules.
- Leave error correction at M, or H if you're adding a logo.
- Keep it dark on light and keep the 4-module quiet zone.
- Press Test scan, download SVG for print, and scan one printed proof with two different phones.
Static vs dynamic
Plenty of QR sites give you a dynamic code by default: the pattern holds their short link, which redirects to yours. That lets them count scans, and lets them switch the code off if you stop paying. Codes from this site are static: the pattern is your link. Nobody sits in the middle, nothing expires and nobody logs who scanned it. If you need to change the destination later, point the code at a page on your own website and update that page.
Questions
How do you make a QR code?
Open a generator, choose what the code should do (open a link, join Wi-Fi, save a contact), enter the details, then download it as PNG or SVG. Test it with a phone before printing.
What is the difference between a static and a dynamic QR code?
A static code stores the content itself and works forever with no service behind it. A dynamic code stores a short redirect link owned by a provider, which lets them change the destination and count scans, but it stops working if the provider or your subscription goes away.
How much data can a QR code hold?
The largest (version 40, level L) holds 2,953 bytes, 4,296 alphanumeric characters or 7,089 digits. In practice keep it to a short URL: fewer characters mean bigger modules that scan faster.
Who invented the QR code?
Masahiro Hara and his team at Denso Wave, a Toyota group company, in 1994, to track car parts on production lines. It is standardised as ISO/IEC 18004 and the patent is not enforced, so anyone may use it freely.