How It Works

How QR Codes Actually Work

How QR Codes Actually Work

You scan a QR code to pay for chai, join a Wi-Fi network, or check a restaurant menu — dozens of times a month for most people. But almost nobody knows what those black-and-white squares are actually doing. It turns out the design is a small masterpiece of engineering.

It's not random — it's binary, arranged in a grid

A QR code encodes data (usually text, like a UPI payment link or a URL) the same way a computer does internally — as a string of 1s and 0s. Each small square, called a "module," is either black (1) or white (0). The pattern that looks like noise to your eye is simply that binary data laid out in a specific, standardised grid.

Different QR "versions" use different grid sizes, from a compact 21×21 grid up to a dense 177×177 grid, depending on how much data needs to fit.

The three corner squares are how your camera finds it

Look closely and you'll notice three identical square patterns in three of the four corners — a solid black square inside a white ring inside a black ring. These are "finder patterns," and they exist purely so your phone's camera can instantly recognise "this is a QR code" and figure out its orientation, even if the code is upside down, sideways, or photographed at an angle.

A smaller fourth pattern near the last corner, called the alignment pattern, helps the scanner correct for any warping if the code is printed on a curved or uneven surface.

Error correction: why a torn or dirty QR code still scans

This is the most underrated part of the design. QR codes use a mathematical technique called Reed-Solomon error correction, which duplicates the encoded data in a clever, distributed way across the whole grid. Depending on the error-correction level chosen when the code was generated, a QR code can lose anywhere from about 7% to a full 30% of its modules — through smudges, tears, a logo printed in the middle, or bad lighting — and still be read perfectly.

This is also why you'll sometimes see a company logo placed in the centre of a QR code. At the higher error-correction settings, the code can afford to have that chunk of data "missing" and still reconstruct the full message from the redundant data elsewhere in the grid.

From squares back to a link, in a fraction of a second

When your camera scans the code, it decodes the grid back into binary, uses the error-correction data to fix any damaged sections, and reconstructs the original text. Your phone then recognises the pattern of that text — a URL, a UPI intent link, Wi-Fi credentials — and offers the matching action, like opening a browser or your payments app.

Why QR codes replaced barcodes for so many uses

A traditional 1D barcode stores data in only one dimension — a single line of varying bar widths — which limits it to a fairly short string, usually just a product number. A QR code stores data in two dimensions, both across and down, which lets it hold vastly more information (up to a few thousand characters) in roughly the same physical space. That's the entire reason QR codes could carry a full payment link or Wi-Fi password where a barcode never could.

Frequently Asked Questions

Can a QR code be dangerous to scan?

The code itself is just data — it can't run code or install malware on its own. The risk is the same as clicking any unfamiliar link: a malicious QR code can point to a phishing website or a fake payment page. Only scan codes from sources you trust, and check the destination before entering any personal details.

Do QR codes expire?

A standard QR code doesn't expire — it's just static data. What can expire is the destination it points to, like a payment link or a promotional page taken offline by whoever created it.

Continue Reading

How Does UPI Actually Work?

UPI moves billions of transactions a month in India, instantly and for free. A clear,…