Codes and signals
How a QR code holds a message
A QR code is a grid of dark and light squares. Each square is one bit, and the grid is built so a phone can read it fast, at any angle, even with a corner torn off. Every code on this page is a real one, made right here in your browser by the same steps a QR maker follows, so your phone can scan any of them. Type your own message and every part below updates.
1. Letters become bits
A computer already stores every letter as a byte: eight bits, each a 0 or a 1. A QR code writes those bits as squares, dark for 1 and light for 0. Before the letters come two short labels: what kind of data follows, and how many bytes of it there are. Then the code adds extra bytes for fixing damage, which part 5 is all about.
Point your phone’s camera at the code: it reads back exactly what you typed. Longer messages need more squares, so the code grows in steps of four squares a side. The sizes are called versions: version 1 is 21 × 21, and this page goes up to version 10, which is 57 × 57.
kind of data (0100 means bytes)how many bytesyour messageend markerpadding
2. Landmarks
Not every square carries your message. Some form fixed shapes that help the camera find the code, line it up, and learn how to read it. Pick a part to light it up.
3. The zigzag
The bits go in two columns at a time, starting in the bottom-right corner. They snake up to the top, step left, snake down, and so on, hopping over every landmark on the way. Your message goes in first, then the error-correction bytes. Each byte usually lands as a little 2 × 4 block.
message or padding byteerror-correction bytenot filled yetlandmark
These are the bits before the mask in part 4 is applied, so long runs of padding still look stripy.
4. Masks: breaking up patterns
Raw bits can make big blank patches, long stripes, or shapes that look like the corner squares, all of which confuse a camera. So the maker flips some squares using a mask: a fixed pattern laid over the message area. There are eight masks. The maker tries all eight, scores each result for trouble, and keeps the lowest score. The format strips record which mask was used, so the reader can flip the same squares back.
Trouble score for each mask (lower is better):
5. Surviving damage
The extra bytes are made with a Reed–Solomon code. The maker treats the message bytes as numbers in a long formula and works out extra bytes that make the whole thing fit an exact mathematical pattern. If some bytes get damaged, the pattern breaks, and the reader can work backwards to find which bytes are wrong and what they should be. It takes two extra bytes to fix each damaged byte: one to find where it is, one to find what it was. Choose more protection and the code grows to make room.
damaged byte, fixeddamaged byte, too manyroom to fix“3 of 9” means 3 damaged, room to fix 9
Each row is one block of bytes. Bigger codes split their bytes into several blocks, each with its own error correction, and spread every block across the whole code, so one big stain hurts many blocks a little instead of one block a lot. The brush skips the three corner squares: without them, a camera can’t find the code at all. Try scanning the damaged code with your phone too.