Skip to content
StylQR home
QR Code Guides

How Do QR Codes Work? What Happens When You Scan One

How a QR code stores text in a grid of squares, how your phone finds, decodes and repairs it when you scan, and what data is or isn't shared before you tap.

By StylQR Editorial TeamPublished Updated 8 min read

StylQR blog cover: How Do QR Codes Work? What Happens When You Scan One, illustrated with a processor chip with a QR code, a binary tree and a focus target on a forest green background
Table of contents

A QR code works by turning text into binary, adding error-correction data, and laying the bits out in a square grid of dark and light modules alongside fixed patterns that help a camera find and straighten it. When you scan one, your phone reverses the process: it locates the code, reads each module, repairs damage, turns the bits back into text, and shows you a prompt. Nothing opens until you tap.

Below is the anatomy of a code, how a generator builds one, what your phone does in the second it takes to scan, and what information leaves your phone (usually less than people fear).

The parts of a QR code

Every QR code has the same anatomy, even when it's styled with rounded dots and colors:

PartWhereWhat it's for
Finder patternsThree large squares in the cornersLet the scanner find the code and its rotation
SeparatorsWhite border around each finderKeep finders distinct from the data
Timing patternsDotted lines between the findersTell the scanner the module grid spacing
Alignment patternsSmall squares (version 2 and up)Correct for curves and perspective
Format informationStrips next to the findersStore the error-correction level and mask
Version informationBlocks near two finders (version 7 and up)Store the version number
Data and error correctionEverything elseYour content plus repair data
Quiet zoneBlank margin outsideSeparates the code from its surroundings

Denso Wave's specification asks for a four-module margin on all sides. That margin is part of the code, even though nothing is printed in it.

How a generator builds a code

Encoding mode and version

The generator first picks the most compact mode for your content:

  • Numeric: digits 0–9 only. Three digits pack into 10 bits.
  • Alphanumeric: digits, uppercase A–Z, space and nine symbols ($ % * + - . / :). Two characters pack into 11 bits.
  • Byte: any data, usually text in UTF-8, at 8 bits per byte. Most links end up here because they contain lowercase letters.
  • Kanji: Japanese characters at 13 bits each, a nod to the format's origins.

The stream starts with a mode indicator and a character count, then the data, a terminator and padding. Some encoders mix modes within one code to save space.

QR codes come in 40 sizes, called versions. Version 1 is 21 × 21 modules and version 40 is 177 × 177, with four modules added per side at each step. The generator picks the smallest version that fits, which is why short content gives an open pattern and long content a dense one. At version 40 with the lowest error correction, a code holds up to 7,089 digits, 4,296 alphanumeric characters or 2,953 bytes. How much data a QR code can store has the practical limits.

Error correction

The data is split into 8-bit codewords, and Reed-Solomon error-correction codewords are calculated and appended. Denso Wave chose Reed-Solomon because it handles concentrated burst errors well, the kind you get from a scratch, a fold or a logo covering one area.

LevelRoughly recoverable
L7%
M15% (Denso Wave notes it's the most common choice)
Q25%
H30%

Larger versions split the data into several blocks, each with its own error-correction codewords, and interleave them. Damage in one spot then hits several blocks a little rather than one block heavily.

Placement, masking and format information

The fixed patterns go down first, then the data bits fill the rest in a zigzag path, two columns at a time, from the bottom right. Every generator puts every bit in the same place for a given version.

Raw data can produce big solid blocks or shapes that look like a finder pattern mid-code. So the generator tries each of eight mask patterns, which flip modules by a simple rule such as "row plus column is even", scores each result against penalty rules, and keeps the best one. Masks apply only to the data area.

Finally it writes 15 bits of format information (the error-correction level and the mask, protected by their own error-correcting code) twice, beside the finders. Codes at version 7 and up also get two copies of version information.

What happens when you scan a QR code

1. The camera spots the code

Your camera app watches the video feed while it's open. When it sees the three nested corner squares, it knows a QR code is in view. Finder patterns keep the same proportions from every angle, so Denso Wave describes QR codes as readable from any direction in 360°. The phone works out the code's position, size and rotation, then corrects for perspective so a tilted code becomes a flat grid again. This is why a missing quiet zone causes trouble: the scanner needs empty space to tell where the pattern ends.

2. The grid becomes bits

The phone uses the timing patterns to count rows and columns, samples each module as dark or light, then reads the format information first. That tells it the error-correction level and which mask to remove to recover the raw data.

3. Error correction repairs the damage

If some modules were misread because of smudges, folds or a logo, the decoder uses the Reed-Solomon data to rebuild them. If the damage is beyond what the level can fix, the phone shows nothing. It won't guess and give you wrong content.

4. The phone decides what the text is

The decoded result is just text. The phone looks at how it starts:

Content starts withWhat the phone offers
https://Open the website in a browser or a linked app
WIFI:Join a Wi-Fi network
BEGIN:VCARDSave a new contact
mailto:Start an email draft
tel:Call a number
sms:Start a text message
geo:Show a place on a map
upi://payOpen a UPI payment app (India)
anything elseShow the text on screen

On an iPhone, the Camera app shows a yellow link or banner, and Apple's instructions are to hold the phone so the code appears, then tap the link. Android phones do the same through the camera app or Google Lens, though the prompt's look depends on the phone maker. Some links open apps: a wa.me link opens WhatsApp and a Google Maps link opens Maps, if installed. How to scan a QR code has phone-by-phone steps.

5. You tap, and only then does anything load

Up to this point everything has happened on your phone, offline. The code is a picture of text, not a program; it can't install anything or run code on its own. When you tap a web link, your browser loads the page as if you'd typed the address, and the site sees what any site sees: your IP address (a rough location), browser and device type, and the time. Joining Wi-Fi, saving a contact or reading plain text works in airplane mode.

Does scanning a QR code track you?

It depends on the type of code, not on scanning itself.

  • Static codes hold the final destination in the pattern. Scanning one tells nobody anything; only the website you open sees the visit. StylQR makes static codes, generated in your browser, so StylQR never sees what's in them or who scans them.
  • Dynamic codes hold a short redirect link run by a QR service. When you open it, that service's server records the visit before sending you on. That's how providers show scan counts by time, device and rough location.

The link preview usually tells you which: the business's own domain is likely a direct link, while a short-link domain belongs to a redirect service. Static vs dynamic QR codes explains the trade-offs.

Where the real risks are

The code can't harm your phone, but the link can take you somewhere unexpected. The common scam is a sticker with a different code placed over a real one, on a parking meter or restaurant table, leading to a page that asks for a card number or login. Read the link preview and check the domain matches the business, be wary of any page that asks you to log in or pay straight after a scan, look for sticker edges, and confirm the payee name in your payment app before approving.

For a second look before opening anything, the StylQR QR code scanner decodes a code from the camera or a screenshot, shows the full content, and checks links for common phishing signs. Are QR codes safe? covers more warning signs.

Why styled codes still scan

Rounded modules, custom eyes and colors work because the scanner only needs to tell dark from light at each module's center and find the three finders. A logo works because error correction rebuilds the modules it covers, which is why StylQR switches to level H automatically when you add one, and why its live scan score warns about low contrast or light-on-dark colors. QR code design best practices covers how far you can push a design.

Note: The format is open. Denso Wave holds the QR Code trademark but chose not to exercise its patent, and the specification is published as ISO/IEC 18004, which Denso Wave lists as approved in June 2000.

Putting it to use

The mechanics explain the usual advice. Keep content short so the version stays small and modules stay large. Keep strong contrast so modules read correctly, leave the quiet zone so the camera finds the edges, and use higher error correction for rough handling. Tell people what they'll get, because the last step depends on them trusting the code enough to tap.

Tip: Code won't scan? Move closer so it fills about a third of the screen, add light and wipe the lens. Why a QR code isn't scanning walks through other causes.

To make one, pick a type from all QR code types or use the free QR code generator, and test the result on two phones before printing. For a broader introduction, start with what is a QR code.

Frequently asked questions

Are QR codes standardized?

Yes. The format is defined in ISO/IEC 18004, which became an international standard in June 2000, after earlier approval as an AIM standard in 1997 and Japanese standard JIS X 0510 in 1999.

Can two different generators make different-looking codes for the same link?

Yes. Generators may choose a different version, error-correction level, encoding mode or mask, so the patterns differ, but every one decodes to the same text.

Does scanning a QR code use mobile data?

Decoding the pattern doesn't; it happens on the phone. Data is only used if the content is a link and you choose to open it, in which case loading the page uses data like any other website.

Can a QR code open an app on its own?

A code can hold a link that an app is registered to handle, such as a WhatsApp or Google Maps link, so tapping it may open that app. The phone still shows you the link first and waits for your tap.

Why are QR codes square?

A square grid with finder patterns in three corners lets a scanner work out position and rotation quickly from any angle, and it stores data in both directions.

Share this guide

StylQR blog cover: How Much Information Can a QR Code Store?, illustrated with a database stack with a hash symbol, layers and a QR code on a emerald background

QR Code Guides

How Much Information Can a QR Code Store?

A QR code holds up to 7,089 digits, 4,296 letters or 2,953 bytes. See how versions, encoding modes and error correction change that, and how much you should store.

· 5 min read

StylQR blog cover: How to Scan a QR Code on Android and iPhone, illustrated with a scanning frame with a camera and Apple and Android icons on a ocean background

QR Code Guides

How to Scan a QR Code on Android and iPhone

Scan QR codes with the camera you already have on iPhone and Android, read codes in screenshots, and fix a phone that won't recognize a code. No app needed.

· 5 min read