Experiment · 2026 · Live
QR Anatomy
See what every square of a QR code is for. Then scratch the code and watch its built-in error correction repair the damage, until there's too much.

QR Anatomy
See what every square of a QR code is for. Then scratch the code and watch its built-in error correction repair the damage, until there's too much.
What it is
A QR code looks like noise, but every square has a job. A few help a camera find the code and line it up. A few say how the rest is encoded. In this one the text itself fills only about a quarter of the squares, and almost half are spare data that can rebuild parts that get damaged.
QR Anatomy builds one code from scratch, labels every square, and lets you damage it to watch the repairs work.
What you can do
- Point at any square. The Inspector names it: a corner finder, a timing mark, format bit 12, or one bit of the spare data. All 8 squares of that byte light up.
- Scratch it. Click, drag, or press Scratch 10. The page re-reads the code after every change and shows each block filling its repair budget, until one overflows and the code dies.
- See how it was built. The bits of the message, the blocks of bytes, the zigzag path they’re laid along, all eight masks with their scores, and the 15 format bits.
Checked against a real decoder
The encoder is about 1,250 lines of Python with no dependencies. To make sure its codes are real ones, the tests have an independent decoder, zxing-cpp, read all 160 combinations of size (versions 1 to 40) and error-correction level, with all 8 masks. Another test checks that the page’s JavaScript decoder agrees with the Python one.
The repair is Reed-Solomon, the classic machinery: Berlekamp-Massey finds where the errors are, with Chien search and Forney’s formula working out the fixes.
Honest limits
The decoder starts from a clean grid of squares. It doesn’t find a code in a photo, so scratches on the corner finders, timing marks and alignment pattern don’t hurt it. Scratches on the format bits do. The encoder runs in Python, not in the page, so this shows one code and you can’t type your own text.
How it was made
This is one of my nightly builds: an AI agent invents, builds and tests a new project every night. QR Anatomy came out of the 22 October 2026 run.