How QR Codes Work: Structure, Error Correction & Capacity
Guide · 8 min read · by the Web Dev Toolkit team
QR codes are everywhere — menus, payment terminals, product packaging, event badges. But under that chessboard of black and white squares there is a well-designed error-correcting system that can still be read when 30% of it is damaged. Here's how it actually works.
Anatomy of a QR code
Every QR code is a grid of modules (the squares), surrounded by a quiet zone of at least four white modules. Inside, three regions matter most:
- Finder patterns — the three large square-in-square markers in the corners. They tell the scanner where the code is and how it's rotated. There is deliberately no fourth corner marker, which lets the reader determine orientation.
- Alignment patterns — smaller markers placed on a grid; they correct for perspective and distortion when the code is printed on curved surfaces.
- Data + error-correction area — everything else: the encoded payload, format information, and Reed–Solomon redundancy bytes.
Versions: how codes grow
QR codes come in 40 versions. Version 1 is 21×21 modules; each version adds 4 modules per side, up to 177×177 for version 40. Bigger versions hold more data but need cleaner printing and larger quiet zones. The table below shows typical maximum capacity at each error-correction level for a moderate version:
| Error level | Fault tolerance | Max digits (v5, 37×37) | Max bytes (v5) |
| L | ~7% | ~106 | ~62 |
| M | ~15% | ~86 | ~49 |
| Q | ~25% | ~66 | ~39 |
| H | ~30% | ~48 | ~29 |
Why error correction matters
Reed–Solomon error correction splits your data into blocks and adds redundancy bytes. The scanner can reconstruct the original payload even if part of the pattern is covered by a logo, scratched, or photographed at an angle. This is why you can safely place a logo in the center of a code made with a high correction level — and why cheap stickers on curved coffee cups still scan.
What limits capacity
- Mode — numeric mode packs ~3 digits into 10 bits, alphanumeric ~2 chars into 11 bits, byte mode 8 bits per char. Numeric is the most efficient.
- Error level — H costs ~2x the space of L.
- Version — bigger grids = more data, but harder to read from a distance.
- Print size — practical rule of thumb: print a code large enough that each module is at least ~1–2 mm on the medium you'll scan.
Practical tips for scannable codes
- Keep content short — a URL under ~100 characters scans better and leaves room for a higher error level.
- Use white quiet-zone padding around the code.
- Never crop or add rounded corners to the finder patterns.
- Test on the device your audience actually uses.
- If the code will be printed on a textured or curved surface, choose level H.
⚡ Make your own: generate fully private, spec-compliant QR codes right in your browser with our
free QR Code Generator — no uploads, no accounts, PNG download included.
Sources: ISO/IEC 18004 (spec), Thonky's QR tutorial, and practical testing with the Web Dev Toolkit QR generator.