Rip 30% Off a QR Code. It Still Works. Here's Why.
Tear it, scribble on it, stick a logo in the middle, and a QR code still scans. Here's how: the three squares in the corners, the hidden ruler, the eight masks, and the maths, called Reed–Solomon error correction, that rebuilds up to 30% of lost data. It also explains why covering just one corner can break it.
The QR code on screen is real. Scan it.
Chapters
- 0:00It still works
- 0:23Try it yourself
- 0:43What a QR code really is
- 1:10Born in a car factory
- 1:38From stripes to a grid
- 1:56Finding the code
- 2:14The 1:1:3:1:1 secret
- 3:08Hidden helpers
- 3:32How the data snakes
- 3:55Eight masks
- 4:22Reed–Solomon error correction
- 5:06Four levels of protection
- 5:27Why a tear doesn't kill it
- 5:46Why logos work
- 6:08The price of toughness
- 6:34The code's eyes
- 6:53Free for everyone
- 7:12CDs and Voyager 2
- 7:37What your phone just did
Read the transcript
I just tore this QR code apart. And it still works. Scribble across it. Still works. Stick a logo in the middle.
Still works. This little square was built to survive damage. So how does your phone know what was there before you ruined it? The answer involves a car factory, a tall building, a board game, and some very clever maths. You can test this yourself.
Find any QR code: on a menu, a poster, a box. Cover a small part of it with your fingertip, away from the corners, and scan it. Most of the time, it still works. Now cover one of the big squares in the corners instead. Watch what happens.
We'll come back to that. First, what is a QR code? It's a grid of tiny squares called modules. Each one is either dark or light, and each one is a single bit: dark means one, light means zero. Group eight bits together and you get a byte, enough for one letter.
Your phone reads the grid, turns it into ones and zeros, and those spell out a website link, a payment, or a Wi-Fi password. The QR code was born in 1994, at Denso, a Japanese company that makes car parts. Its factories tracked parts with ordinary barcodes, those rows of black stripes. But a barcode holds only about 20 characters. A team of just two engineers, led by Masahiro Hara, set out to build something better: a code that could hold far more, be read fast from any angle, and survive a dirty factory floor.
Hara has said that part of the idea came from the board game Go. A Go board is a grid of black and white stones, and the whole game lives in that grid. Why read one line of stripes, when you could read across and down at the same time? That's what makes a QR code two-dimensional. But a camera sees a messy world.
The code is tilted, curved around a bottle, half in shadow. So before reading any data, your phone has to find the code and work out which way is up. That's the job of the three big squares in the corners. They're called finder patterns. Hara has described seeing a tall building from a train window, standing out clearly from everything around it.
The code needed a mark like that, one that could not be mistaken for anything else. So the team studied printed material, like flyers, magazines and cardboard boxes, and measured their patterns of black and white. They picked the ratio that appeared least often: one, one, three, one, one. Draw a line through the centre of a finder square and you cross one unit of black, one of white, three of black, one of white, and one of black. That ratio stays the same whichever way the line goes, so the phone can spot it at any angle.
Find all three, and it knows where the code is, how big it is, and how it's turned. The empty fourth corner tells it which way is up. There are other helpers hidden in the grid. Between the corners runs a dotted line of black and white, like a ruler, so the phone can count the columns. Bigger codes add small extra squares, called alignment patterns, which help when the code is bent or seen at a sharp angle.
And around the outside there should be an empty border, so the code doesn't blend into whatever is printed next to it. Then comes the data itself. It starts in the bottom right corner and zigzags upward in a narrow column, two squares wide, then turns and snakes back down, weaving around the corner squares. Near the finder patterns, a small strip records the code's settings. That strip is stored twice, in two different places, in case one copy gets damaged.
Before a code is printed, there's one more step. If the data happened to make a big black blob, or a shape that looks like a finder pattern, the phone could get confused. So the generator tries eight different masks. Each mask flips some squares in a fixed pattern, like a checkerboard or stripes. All eight are scored, and the cleanest one wins.
Your phone reads which mask was used, and flips the squares back. Now the clever part: surviving damage. You could simply print the data twice. But that doubles the size, and if both copies get hit in the same place, you're stuck. Instead, QR codes use a mathematical recipe called Reed–Solomon error correction.
It builds extra check squares, calculated from the real data. Here's a way to picture it. Imagine I tell you: two numbers add up to 10, and the first one is 3. Even if you lose the second number, you can work it out. It's 7.
Reed–Solomon does the same thing, but with hundreds of numbers tied together by many equations at once. Lose some, and the rest let you rebuild them. When a QR code is made, the creator picks how much protection it gets. There are four levels. The lowest can recover about 7 percent of the data.
Then 15, then 25. The highest, level H, can rebuild about 30 percent. Almost a third of the code's data can be lost, and it still reads. Larger codes add another trick. Their data isn't stored as one long block.
It's split into several blocks, and the pieces are woven together across the grid. So when you tear off one edge, the damage is shared between several blocks, and each block only has to repair a little. That's the secret behind QR codes with logos in the middle. Designers cover part of the code with a picture, usually at level H and well away from the corners, and let error correction rebuild what's hidden. The logo isn't fitting around the code.
It's damaging it, on purpose, and the maths quietly repairs it every time you scan. But nothing is free. The more protection you add, the more squares are spent on check data instead of your message. To hold the same link, a level H code needs a bigger, denser grid than a level L one. QR codes come in 40 sizes, from a 21 by 21 grid up to a giant 177 by 177, which can hold over 7,000 digits.
Remember the test from the start? Here's why covering a corner square is different. Error correction can only work after the phone has found the code. Hide or tear off a finder pattern, and your phone may never lock on, however much of the data survives. The corners are the code's eyes.
There's one more reason QR codes are everywhere. Denso held the patent, but chose not to enforce it, so anyone could make and read QR codes for free. It became an international standard in 2000, and today you'll find them on menus, tickets and payment stands all over the world. And this idea isn't only in QR codes. Music CDs use Reed–Solomon codes too, and can fully correct a scratch about two and a half millimetres long.
Voyager 2 used them to send home its pictures of Uranus and Neptune, billions of kilometres away. Whenever data has to survive a messy journey, engineers add clever extra information to rebuild what gets lost. So the next time you scan a crumpled menu, remember what happens in that half second. Your phone finds three squares, reads the grid, undoes the mask, notices the damage, and solves a set of equations to rebuild what's missing. A car factory, a tall building, a board game and some clever maths, in a square on your table.
Next on Kurioso: what would happen if every satellite above us switched off tomorrow? It's not just your maps that would break. Subscribe so you don't miss it. Stay curious.