Skip to content
Urlzee

How Do QR Codes Work? A Plain-English Explanation

By Urlzee Team · Published · 6 min read

A QR code is text written as a grid of dark and light squares. Each square stands for a binary digit. A phone camera locates the grid using the three large corner markers, reads the squares as ones and zeros, repairs any errors using built-in redundancy, and converts the result back into text, most often a web address.

What is a QR code?

A QR code is a two-dimensional barcode. An ordinary barcode stores data in one direction, as a row of lines of varying width. A QR code stores it in two directions, across and down, which lets it hold far more in the same area.

QR stands for "quick response". The format was created in 1994 by the Japanese company Denso Wave to track parts in car manufacturing, where it needed to be read quickly and from any angle.

The individual squares are called modules. A dark module represents 1 and a light one represents 0.

What are the parts of a QR code?

A QR code is not all data. A good share of the pattern exists to help the scanner find and interpret the rest.

PartWhat it looks likeWhat it does
Finder patternsThree large squares in the cornersLocate the code and show its orientation
Alignment patternsSmaller squares inside the code (larger codes only)Correct for curved or tilted surfaces
Timing patternsAlternating dark and light modules between the findersEstablish the size of the module grid
Format informationStrips beside the finder patternsRecord the error correction level and mask used
Data and error correctionEverything elseThe stored content plus redundancy
Quiet zoneBlank margin around the outsideSeparates the code from its surroundings

The finder patterns are the clever part. Each one is a dark square inside a light ring inside a dark ring, giving a dark-light-dark-light-dark sequence in the proportions 1:1:3:1:1 when crossed through the centre in any direction. That ratio is unlikely to occur by chance in a photograph, so a scanner can spot it quickly. There are three of them, not four, and the empty corner tells the scanner which way is up.

The quiet zone is easy to overlook and matters a great deal. The standard calls for a margin four modules wide on every side. Crop it away or run a design element into it and many scanners will fail to lock on.

How does a phone read a QR code?

Scanning is a short chain of image processing and arithmetic.

  1. Find it. The camera software searches the image for the three finder patterns.
  2. Straighten it. From the positions of the finders, and alignment patterns in larger codes, it corrects for angle, rotation and perspective.
  3. Lay out the grid. The timing patterns show how many modules there are and where their centres lie.
  4. Sample each module. The scanner decides whether each grid position is dark or light.
  5. Read the format information. This reveals the error correction level and which mask was applied.
  6. Remove the mask. The masking pattern is reversed to recover the original bits.
  7. Correct errors. The redundancy data is used to detect and repair wrong or unreadable modules.
  8. Decode. The bits are converted back into characters according to the encoding mode.
  9. Act. The phone shows the text or, if it is a URL, offers to open it.

Nothing in this process involves the internet. The content is entirely in the printed pattern. A connection is only needed at the last step, if the content is a web address you choose to visit.

How is the data turned into squares?

The text is converted to bits, padded and protected with error correction, arranged in the grid, then masked. In more detail:

Encoding modes. QR codes have several ways of packing characters into bits, each efficient for a different kind of content:

  • Numeric for digits only
  • Alphanumeric for digits, capital letters and a few symbols
  • Byte for general text, which is what a typical URL with lowercase letters uses
  • Kanji for Japanese characters

The encoder picks the mode that fits the content, and digits-only data takes the least space.

Placement. The bit stream, data followed by error correction, is written into the grid in a zigzag path starting from the bottom right, skipping the areas reserved for the fixed patterns.

Masking. Raw data can produce awkward results: large blank areas, or shapes that resemble a finder pattern. To avoid that, the encoder flips modules according to one of eight fixed mask patterns and keeps the version that scores best for readability. The chosen mask is recorded in the format information so the scanner can undo it.

How does error correction work?

Error correction adds extra data calculated from the content, so missing parts can be reconstructed. QR codes use a method called Reed–Solomon coding, also used on optical discs and in digital broadcasting.

There are four levels. Each trades capacity for resilience.

LevelApproximate share of the code that can be restored
L (low)7%
M (medium)15%
Q (quartile)25%
H (high)30%

A higher level means more modules for the same content, so the pattern is denser. Level M suits most everyday uses. Higher levels are worth it for codes that may get scratched, creased or dirty. The trade-offs are covered in QR code error correction levels.

How much can a QR code hold?

Capacity depends on the code's size, called its version, and the error correction level. There are 40 versions. Version 1 is a 21 × 21 grid, and each version adds four modules per side, up to 177 × 177 for version 40.

At its largest and with the lowest error correction, a QR code can store up to 7,089 digits, 4,296 alphanumeric characters or 2,953 bytes.

Those are ceilings, not targets. For anything meant to be scanned by the public, less data is better: fewer characters means fewer, larger modules, and larger modules are readable from further away and in worse light.

A shorter URL needs a lower version, which means bigger modules at the same printed size. The difference is visible. A long address with tracking parameters might need a grid of 40 or more modules per side, while a short link such as https://urlzee.com/menu fits comfortably in one of the smallest versions.

A code containing a short link can also be measured and updated: each scan passes through the link and is counted, and if the destination is editable, the printed code can point somewhere new. A code that contains the final address directly is called static; one that contains a redirecting link is called dynamic. Static vs dynamic QR codes explains when to choose each.

To try it, shorten your address with the URL shortener, then generate a code from the short link with the QR code generator. The generator runs in your browser, lets you set colours, size and error correction level, and downloads as PNG or SVG.

Why do some QR codes fail to scan?

A code fails when the scanner cannot complete one of the steps above. Knowing the mechanics makes the causes easy to predict:

  • No quiet zone, so the finder patterns cannot be isolated.
  • Low contrast, so dark and light modules cannot be told apart. Dark on light is the dependable choice.
  • Modules too small for the camera to resolve at the scanning distance, usually from too much data or too small a print.
  • Too much damage or too large a logo, beyond what error correction can rebuild.

Each of these has a straightforward fix, set out in why is my QR code not scanning?

A QR code looks cryptic, but nothing is hidden in it. It is plain text in a machine-readable form, with fixed landmarks so a camera can find its place and enough redundancy to survive rough handling.

Frequently asked questions

How does a QR code work?
A QR code stores data as a grid of dark and light squares. A phone camera finds the three corner markers, works out the grid, reads the squares as binary digits, corrects any errors, and turns the result back into text such as a web address.
Does a QR code need the internet to work?
Reading the code does not. The data is in the pattern itself, so a phone can decode it offline. An internet connection is only needed afterwards if the decoded text is a web address you want to open.
What are the three big squares in the corners of a QR code?
They are finder patterns. They let a scanner locate the code, work out its size and determine which way up it is, so it can be read at any angle.
How much data can a QR code hold?
The largest version holds up to 7,089 digits, 4,296 alphanumeric characters or 2,953 bytes at the lowest error correction level. Practical codes hold far less, because denser patterns are harder to scan.
Can a QR code still scan if it is damaged?
Often, yes. QR codes include error correction data that can rebuild missing parts, from about 7% of the code at the lowest level to about 30% at the highest.