How Does a QR Code Work? What's Really Inside That Square
You point your phone at a little black and white square. A second later, a website opens, a Wi-Fi network connects, or a payment screen appears. It feels like magic. Here is how it actually works, in plain language.
The short answer
A QR code is a grid of tiny black and white squares called modules. Together they spell out a message in a simple code, the same way letters spell words. Your phone's camera sees the grid, works out how it's turned and sized, reads the squares, fixes any mistakes, and turns them back into text, like a link.
What's inside a QR code
Every QR code has the same set of parts. Some help the scanner find the code. Others hold the actual message.
The three big squares in the corners
These are the finder patterns. They are the first thing a scanner looks for. Each one is built from dark, light and dark rings in a fixed ratio, which is unusual enough that it rarely appears by accident in normal printing.
There are three, not four, on purpose. Because one corner is missing, the scanner can tell which way up the code is, even if you hold it sideways or upside down.
The small square and the dotted lines
Larger codes have smaller squares inside called alignment patterns, which help the scanner fix any bending or tilt. Two lines of alternating black and white dots, called timing patterns, run between the big squares. By counting them, the scanner learns the exact size of each module and can lay an accurate grid over the whole code.
The blank border
Around the code is a plain empty margin called the quiet zone. The standard asks for at least four modules of space. It keeps nearby text, pictures or edges from being mistaken for part of the code.
The format information
Near the big squares, a small strip of modules tells the scanner two things: how much error correction the code uses, and which mask pattern was applied.
The data area
Everything else is the message itself, plus extra backup data used to fix errors. This is the speckled part that looks like random noise, but is actually precisely encoded data.
How your phone reads a QR code, step by step
- The camera takes a picture and turns it into high-contrast black and white.
- The software searches for the three finder patterns in the corners.
- It works out how the code is oriented and straightened using alignment and timing patterns.
- It reads the format information to learn the error correction level and the mask.
- It removes the mask pattern and reads the modules in a zigzag path across the grid.
- It uses the backup data to fix any mistakes, such as a smudge or a blurry spot.
- It turns the result back into readable text (URL, Wi-Fi credentials, text, contact).
Why a damaged QR code can still work
When a code is made, extra backup data is added using Reed-Solomon error correction. If part of the code is dirty, torn or covered by a logo, the scanner uses the backup data to rebuild what is missing.
The four levels (L, M, Q, and H) can restore approximately 7%, 15%, 25%, and 30% of damaged data, allowing codes with logos in the middle to still scan seamlessly.
Frequently Asked Questions
Can a QR code have a virus?
The code itself is just text data. The risk is where it sends you. A malicious code can point to a phishing or malware website, so always check the previewed URL before opening.
Why do QR codes have three big squares?
They let the scanner find the code and determine its orientation immediately, regardless of what angle the phone is held.
Do QR codes expire?
Static QR codes never expire because data is baked directly into the square pattern. Dynamic codes depend on the forwarding service staying active.
Do QR codes need the internet?
No. Decoding happens completely offline on your device. You only need internet if the decoded content is a website address you wish to visit.