How QR Codes Work: How a Square of Shapes Takes You to a Website

Published 16 October 2026 by the QRCodeBarn team.

You point your phone at a little black-and-white square and, a moment later, a web page opens. It feels like magic, but every part of that square has a job. This guide explains, in plain English, what is actually inside a QR code and what your phone does with it.

Modules: the code is made of bits

A QR code is a grid of small squares called modules. Each module is either dark or light, and in the simplest terms a dark module means 1 and a light module means 0. So a QR code is really a block of binary data printed as a picture.

The grid comes in 40 sizes, called versions. Version 1 is 21 × 21 modules, and each version adds four modules per side, up to Version 40 at 177 × 177. The more information you store, the bigger the version, and the busier the code looks.

Not every module holds your data, though. A good part of the code is set aside for patterns that help the scanner.

The patterns that help your phone

Finder patterns. The three large squares in the corners. Each has the same distinctive ratio of black to white, 1:1:3:1:1, whichever way you cut across it. That ratio was chosen because it rarely appears in ordinary print. When your camera spots three of them, it knows it has found a QR code and which way up it is. The fourth corner is empty, and that is how the phone tells which corner is which. (For the story of how they were designed, see our history of the QR code.)

Separators. A one-module white strip around each finder pattern, keeping it apart from the data.

Timing patterns. Two lines of alternating dark and light modules running between the finder patterns, one horizontal and one vertical. They act like a ruler, telling the scanner how big each module is and where the rows and columns fall, even if the image is a little warped.

Alignment patterns. Smaller squares with a dot in the middle, found in Version 2 codes and above. Larger codes have several. They help the scanner correct for distortion when the code is photographed at an angle or printed on a curved surface.

Quiet zone. The clear border around the outside, at least four modules wide under the standard. It tells the scanner where the code ends. Our QR code size guide explains why you should never crop it.

Format and version information

Next to the finder patterns are small strips of format information. They record two things the scanner needs before it can read anything else: the error correction level and the mask pattern used (more on both below). This information is so important that it is stored twice, in two different places.

Codes of Version 7 and above also carry version information in two small blocks near the corners, so the scanner can confirm the grid size.

Encoding modes: turning text into bits

Before it is drawn, your content is converted into bits using one of several encoding modes, defined in the QR code standard ISO/IEC 18004:

A code can switch modes partway through to save space. At its largest, a QR code can hold up to 7,089 digits, or 2,953 bytes of general data, at the lowest error correction level.

Error correction: how a damaged code still scans

QR codes use Reed-Solomon error correction, the same family of maths used on CDs and DVDs. Put simply, the code stores your data plus some carefully calculated extra data. If part of the code is scratched, smudged or covered, the scanner can use the extra data to work out what is missing.

There are four levels:

Higher levels make a code tougher, which is why codes with a logo in the middle use them. The trade-off is that more error correction means more modules, so the code is denser.

Masking: avoiding confusing patterns

Raw data can produce awkward patterns, such as large solid blocks or something that looks like a finder pattern in the middle of the code. To avoid this, the generator applies one of eight mask patterns. A mask is a fixed rule that flips certain modules from dark to light and back. The generator tries all eight and picks the one that gives the most even, easy-to-read result. The scanner reads which mask was used from the format information, then reverses it.

What your phone actually does when it scans

When you open your camera and point it at a code, the phone runs through roughly these steps in a fraction of a second:

  1. Find it. The software searches the camera image for the three finder patterns.
  2. Straighten it. Using the finder and alignment patterns, it works out the code's angle and perspective and maps it back to a flat, square grid.
  3. Measure the grid. The timing patterns tell it the module size, and the version tells it how many rows and columns to expect.
  4. Read each module. It samples the centre of every module and decides whether it is dark or light.
  5. Read the format information to learn the error correction level and mask, then remove the mask.
  6. Correct errors. Reed-Solomon decoding repairs any modules that were misread or damaged.
  7. Decode the text. The bits are turned back into characters using the encoding mode.
  8. Act on it. If the text is a web address, the phone offers to open it.

The code doesn't contain the website

This is the part that surprises people. A QR code doesn't store a website, an app or a video. In most cases it just stores a short piece of text, such as https://www.qrcodebarn.com/. Your phone reads that text and opens it in the browser, exactly as if you had typed it in.

Other types work the same way. A Wi-Fi code stores text in a set format containing the network name and password. A contact code stores a vCard, and an email code stores a mailto: link. Your phone recognises the format and offers the right action. That is also why a QR code needs an internet connection to open a web page, but not to be read.

Static vs dynamic QR codes

A quick safety note: check before you tap

Because a QR code is just a link, it can point anywhere, including to a scam. Fraudsters sometimes stick fake codes over real ones on parking meters, posters or menus to send people to look-alike payment pages. This is sometimes called "quishing". To stay safe:

Frequently asked questions

Does a QR code store the website itself?

No. It usually stores the web address as text. Your phone reads the address and opens it in your browser.

Why can a QR code still scan when part of it is damaged?

QR codes use Reed-Solomon error correction, which adds extra data so the scanner can rebuild missing parts. At the highest level (H), roughly 30% of the code can be restored.

What are the three big squares in the corners for?

They are finder patterns. They let your phone find the code quickly and work out which way up it is, from any angle.

Do QR codes expire?

Static QR codes don't, because the destination is stored in the code itself. A dynamic code can stop working if the redirect service behind it is switched off or the subscription ends. Either kind fails if the website it points to is taken down.

Can a QR code be dangerous?

The code itself is just text, but it can link to a scam website. Always check the address in your phone's preview before opening it, and be careful with codes that ask for payment.

Further reading

Learn where QR codes came from, or read our QR code size guide before you print your own.

This article was drafted with AI assistance and reviewed for accuracy. Read our editorial policy and AI content policy.