How Data is Encoded in a QR Code

Posted by Nicholas M. Roberts

One question I am consistently frustrated with is “how do QR codes work?” I don’t mean “how do I scan them” or “what can they do,” I literally mean “how does it work?” What is the reader seeing that I’m not and how is data encoded in a scrambled maze of contrasting-colored boxes? I once asked this question several times each day and it still took me weeks to discover a solid answer. Now I hear it being asked all the time by others. Most online tutorials avoid this topic entirely and instead choose to focus on which app is best and how to scan a code. Even the official ISO website charges a hefty sum to even read about encoding. To end your search suffering, I will now reveal how QR codes work from a technical standpoint.

As much as I hate to link you there, Wikipedia actually has the best diagram for how a 2D barcode is read. The one used in the linked image is actually a Data Matrix code, but QR works much the same. Essentially, the code tells your reader where to start reading and where to stop reading. Along the way it passes through predetermined, but invisible segments in a zigzag pattern. Each segment has a combination of light or dark squares that matches an alphanumeric character. This system is quite similar to Braille.

If QR codes follow a pattern with the way they display letters, shouldn’t I be able to read with the naked eye?

The boxes are of varying sizes and certain letters may be structured in one box differently than another. Theoretically if you learn all of the rules you would be able to read a QR code, but it would take exponentially longer than using a reader and you wouldn’t be able to access the website automatically afterward.

If a website can be accessed from paper, what do we need computers for?

Neither the website nor the data on it are stored in the QR code. Only the address is. Your reader scans a code and receives the characters H-O-W-T-O-M-A-K-E-A-Q-R-C-O-D-E-.-B-I-Z in order. It then sends these letters through a web browser and returns the webpage. If I just type Facebook.com, you can do nothing with it, but if I send you a link to facebook.com, you can interact with your friends, check up on your favorite music artists and complain about Facebook’s latest layout change.

There is certainly more to the process, but my goal with this post was simply for you to think “oh, I get it” and you certainly couldn’t do that if you were barraged with technical terminology. If you are hungry for more information, consult the How Tutorial