# How QR Codes Work: Scanning, Decoding, and Examples

> A practical explanation of how QR codes are detected and decoded, plus real examples of URL, Wi-Fi, email, phone, and SMS QR payloads.

Canonical: https://fast-qr.app/learn/how-qr-codes-work
Last updated: 2026-09-30

Author: [Rehan Haider](https://fast-qr.app/author/rehan-haider)
Published: 2026-04-15
Tags: qr, how it works, decoding, examples, error correction

A QR code is a two-dimensional barcode that stores data in a square grid of dark and light modules; phones decode that data through a multi-step pipeline. Scanning a QR code feels instant, but a lot happens in that fraction of a second. The camera finds a square pattern in a moving image, corrects for the angle you're holding the phone at, reads thousands of dark and light cells, repairs whatever is missing or smudged, and finally turns the bytes into something the phone can act on, like a URL or a Wi-Fi join request.

Understanding the pipeline is useful because it explains why some codes scan beautifully on a designer's monitor and fail on a printed menu. Most failures aren't about encoding. They're about something earlier in the chain breaking before decoding can even start.

This guide walks through the full flow from camera frame to action, then shows the literal payload strings for each common QR type, then explains where things go wrong in the real world.

## Key takeaways

- A QR scan is a two-stage process: computer vision (find the code, square it up, sample the module grid) then data decoding (Reed–Solomon error correction, payload parsing).
- Most printed-code failures happen in the first stage — too small, too low-contrast, missing quiet zone — before error correction ever runs.
- The four error-correction levels (L 7%, M 15%, Q 25%, H 30%) determine how much of the pattern can be damaged or covered before scanning fails.
- Common payloads are URL, Wi-Fi (`WIFI:` string), `tel:`, `sms:`, and `mailto:` — each has a specific format the phone OS recognizes and acts on.
- Stylized codes (gradients, rounded modules, photographic backgrounds) interfere with the scanner's threshold detection and fail more often in real-world conditions.

## How does the scan pipeline work?

When you point a phone at a QR code, the scanner runs through these steps in sequence:

1. **Capture frames.** The camera streams images at 30 to 60 frames per second. Each frame is a candidate.
2. **Detect candidates.** The scanner searches for high-contrast square-like regions that resemble finder patterns.
3. **Confirm QR geometry.** It verifies three finder patterns at the right relative positions. If only two appear, or the spacing is off, it skips the frame.
4. **Correct perspective.** It computes a transformation that unwarps the code into a square, even if you're scanning at an angle.
5. **Sample the grid.** It estimates module size and reads each cell as dark or light.
6. **Decode format and version.** It reads small reserved regions that describe the error correction level, mask pattern, and version.
7. **Apply error correction.** It runs Reed-Solomon decoding to repair missing or incorrect modules using redundancy data.
8. **Parse the payload.** It converts the recovered bytes into a recognized type — URL, Wi-Fi string, `mailto:`, `tel:`, plain text.
9. **Present the action.** The phone shows a preview ("Open website") or hands off directly to a system app.

<figure style="margin: 1.5rem auto; max-width: 720px;">
  <svg role="img" viewBox="0 0 720 340" xmlns="http://www.w3.org/2000/svg" style="width: 100%; max-width: 720px; height: auto;">
    <title>QR scan pipeline — nine steps from camera frame to action</title>
    <desc>A flowchart showing the nine-step QR scanning pipeline arranged in three rows. Steps one through nine: capture frames, detect candidates, confirm geometry, correct perspective, sample the grid, decode format, error correction, parse payload, and present action.</desc>
    <rect width="720" height="340" fill="#FAF7F0"/>
    <g font-family="system-ui, sans-serif">
      <g transform="translate(35,25)">
        <rect width="200" height="70" rx="6" fill="#FFFFFF" stroke="#00476b" stroke-width="1.5"/>
        <circle cx="25" cy="35" r="15" fill="#00476b"/>
        <text x="25" y="40" text-anchor="middle" font-size="14" font-weight="700" fill="#FAF7F0">1</text>
        <text x="50" y="28" font-size="12" font-weight="700" fill="#081e32">Capture frames</text>
        <text x="50" y="44" font-size="10" fill="#4a6070">Camera streams 30–60</text>
        <text x="50" y="58" font-size="10" fill="#4a6070">candidate fps</text>
      </g>
      <path d="M 235 60 L 255 60" stroke="#00476b" stroke-width="1.5" fill="none"/>
      <polygon points="255,55 263,60 255,65" fill="#00476b"/>
      <g transform="translate(260,25)">
        <rect width="200" height="70" rx="6" fill="#FFFFFF" stroke="#00476b" stroke-width="1.5"/>
        <circle cx="25" cy="35" r="15" fill="#00476b"/>
        <text x="25" y="40" text-anchor="middle" font-size="14" font-weight="700" fill="#FAF7F0">2</text>
        <text x="50" y="28" font-size="12" font-weight="700" fill="#081e32">Detect candidates</text>
        <text x="50" y="44" font-size="10" fill="#4a6070">Find high-contrast</text>
        <text x="50" y="58" font-size="10" fill="#4a6070">squarish regions</text>
      </g>
      <path d="M 460 60 L 480 60" stroke="#00476b" stroke-width="1.5" fill="none"/>
      <polygon points="480,55 488,60 480,65" fill="#00476b"/>
      <g transform="translate(485,25)">
        <rect width="200" height="70" rx="6" fill="#FFFFFF" stroke="#00476b" stroke-width="1.5"/>
        <circle cx="25" cy="35" r="15" fill="#00476b"/>
        <text x="25" y="40" text-anchor="middle" font-size="14" font-weight="700" fill="#FAF7F0">3</text>
        <text x="50" y="28" font-size="12" font-weight="700" fill="#081e32">Confirm geometry</text>
        <text x="50" y="44" font-size="10" fill="#4a6070">Three finder patterns</text>
        <text x="50" y="58" font-size="10" fill="#4a6070">at the right positions</text>
      </g>
      <path d="M 685 60 L 705 60 L 705 155 L 48 155" stroke="#00476b" stroke-width="1.5" fill="none"/>
      <polygon points="40,155 48,150 48,160" fill="#00476b"/>
      <g transform="translate(35,120)">
        <rect width="200" height="70" rx="6" fill="#FFFFFF" stroke="#00476b" stroke-width="1.5"/>
        <circle cx="25" cy="35" r="15" fill="#00476b"/>
        <text x="25" y="40" text-anchor="middle" font-size="14" font-weight="700" fill="#FAF7F0">4</text>
        <text x="50" y="28" font-size="12" font-weight="700" fill="#081e32">Correct perspective</text>
        <text x="50" y="44" font-size="10" fill="#4a6070">Unwarp into a clean</text>
        <text x="50" y="58" font-size="10" fill="#4a6070">square frame</text>
      </g>
      <path d="M 235 155 L 255 155" stroke="#00476b" stroke-width="1.5" fill="none"/>
      <polygon points="255,150 263,155 255,160" fill="#00476b"/>
      <g transform="translate(260,120)">
        <rect width="200" height="70" rx="6" fill="#FFFFFF" stroke="#00476b" stroke-width="1.5"/>
        <circle cx="25" cy="35" r="15" fill="#00476b"/>
        <text x="25" y="40" text-anchor="middle" font-size="14" font-weight="700" fill="#FAF7F0">5</text>
        <text x="50" y="28" font-size="12" font-weight="700" fill="#081e32">Sample the grid</text>
        <text x="50" y="44" font-size="10" fill="#4a6070">Read each module as</text>
        <text x="50" y="58" font-size="10" fill="#4a6070">dark or light</text>
      </g>
      <path d="M 460 155 L 480 155" stroke="#00476b" stroke-width="1.5" fill="none"/>
      <polygon points="480,150 488,155 480,160" fill="#00476b"/>
      <g transform="translate(485,120)">
        <rect width="200" height="70" rx="6" fill="#FFFFFF" stroke="#00476b" stroke-width="1.5"/>
        <circle cx="25" cy="35" r="15" fill="#00476b"/>
        <text x="25" y="40" text-anchor="middle" font-size="14" font-weight="700" fill="#FAF7F0">6</text>
        <text x="50" y="28" font-size="12" font-weight="700" fill="#081e32">Decode format</text>
        <text x="50" y="44" font-size="10" fill="#4a6070">Mask, version, error</text>
        <text x="50" y="58" font-size="10" fill="#4a6070">correction level</text>
      </g>
      <path d="M 685 155 L 705 155 L 705 250 L 48 250" stroke="#00476b" stroke-width="1.5" fill="none"/>
      <polygon points="40,250 48,245 48,255" fill="#00476b"/>
      <g transform="translate(35,215)">
        <rect width="200" height="70" rx="6" fill="#FFFFFF" stroke="#4a7c59" stroke-width="1.5"/>
        <circle cx="25" cy="35" r="15" fill="#4a7c59"/>
        <text x="25" y="40" text-anchor="middle" font-size="14" font-weight="700" fill="#FAF7F0">7</text>
        <text x="50" y="28" font-size="12" font-weight="700" fill="#081e32">Error correction</text>
        <text x="50" y="44" font-size="10" fill="#4a6070">Reed–Solomon repairs</text>
        <text x="50" y="58" font-size="10" fill="#4a6070">missing or wrong bits</text>
      </g>
      <path d="M 235 250 L 255 250" stroke="#00476b" stroke-width="1.5" fill="none"/>
      <polygon points="255,245 263,250 255,255" fill="#00476b"/>
      <g transform="translate(260,215)">
        <rect width="200" height="70" rx="6" fill="#FFFFFF" stroke="#00476b" stroke-width="1.5"/>
        <circle cx="25" cy="35" r="15" fill="#00476b"/>
        <text x="25" y="40" text-anchor="middle" font-size="14" font-weight="700" fill="#FAF7F0">8</text>
        <text x="50" y="28" font-size="12" font-weight="700" fill="#081e32">Parse payload</text>
        <text x="50" y="44" font-size="10" fill="#4a6070">URL, Wi-Fi, tel:, sms:,</text>
        <text x="50" y="58" font-size="10" fill="#4a6070">mailto:, plain text</text>
      </g>
      <path d="M 460 250 L 480 250" stroke="#00476b" stroke-width="1.5" fill="none"/>
      <polygon points="480,245 488,250 480,255" fill="#00476b"/>
      <g transform="translate(485,215)">
        <rect width="200" height="70" rx="6" fill="#FFFFFF" stroke="#E8A21A" stroke-width="2"/>
        <circle cx="25" cy="35" r="15" fill="#E8A21A"/>
        <text x="25" y="40" text-anchor="middle" font-size="14" font-weight="700" fill="#FAF7F0">9</text>
        <text x="50" y="28" font-size="12" font-weight="700" fill="#081e32">Present action</text>
        <text x="50" y="44" font-size="10" fill="#4a6070">Phone offers Open,</text>
        <text x="50" y="58" font-size="10" fill="#4a6070">Join, Dial, or Send</text>
      </g>
      <text x="360" y="320" text-anchor="middle" font-size="11" fill="#4a6070" font-style="italic">Steps 1–6 are computer vision; step 7 is data recovery; steps 8–9 are payload handling. Failures cluster in 1–3.</text>
    </g>
  </svg>
  <figcaption style="margin-top: 0.5rem; text-align: center; font-size: 0.85rem; color: #4a6070;">The nine-step QR scan pipeline. The first three steps are pure computer vision — they fail when the print is too small, too low-contrast, or missing its quiet zone. Error correction at step 7 only kicks in once a code has already been located and sampled.</figcaption>
</figure>

The big idea: a QR scanner does both computer vision (finding and squaring up the code) and data decoding (interpreting the bitstream). A printed code that survives the first job but breaks the second is rare. The reverse — passing decoding in clean lab conditions but failing computer vision under fluorescent lights — is common.

## Why damaged codes still scan

QR codes carry redundancy. The pattern doesn't only store your payload; it also stores parity data calculated with Reed-Solomon error correction. The encoder picks one of four levels:

- **L (Low).** Recovers up to roughly 7% of damaged modules.
- **M (Medium).** Up to ~15%.
- **Q (Quartile).** Up to ~25%.
- **H (High).** Up to ~30%.

That's how a code keeps working when:

- A corner gets scratched off a sticker on a delivery box.
- A coffee ring blots part of a menu.
- A logo sits on top of the center.
- The print run had inconsistent ink coverage.

Higher levels of error correction add more parity, which means a denser grid for the same payload. If you embed a logo, bump the level up to Q or H so the redundancy can absorb what the logo covers. For more on tradeoffs, see [QR code error correction explained](https://fast-qr.app/learn/qr-code-error-correction-explained).

Redundancy is not a free pass. If the code is too small, low-contrast, or missing the [quiet zone](https://fast-qr.app/learn/glossary#quiet-zone), the scanner gives up before error correction even runs. Error correction repairs decoded data; it doesn't rescue a code the camera couldn't lock onto in the first place.

## How your data becomes modules

When a generator builds a QR code from your input, it goes through these steps:

1. **Pick an encoding mode.** Numeric, alphanumeric, byte, or kanji. URLs and most modern payloads use byte mode.
2. **Convert to bits.** The payload becomes a bitstream.
3. **Add metadata headers.** A short prefix declares the mode and the length of the payload.
4. **Compute error correction.** Reed-Solomon parity bytes are calculated and interleaved with the data.
5. **Place bits into the grid.** Bits map to module positions in a defined zigzag pattern around the reserved regions.
6. **Apply a mask.** One of eight masking patterns gets XORed onto the data area to break up large blocks of same-color modules. The encoder picks whichever mask scores best on standardized scan-friendliness rules.

You don't need to memorize the encoder to publish QR codes, but the mask step matters in practice. It explains why two codes carrying the same URL can look completely different yet scan identically. It also explains why "stylized" codes with rounded modules or heavy gradients can break: they interfere with the scanner's ability to cleanly classify cells as dark or light, which is exactly what masking was designed to optimize.

## Real payload examples

The same QR visual format can carry completely different data. Here's what gets encoded for each common type, plus the practical notes that matter when you generate one.

### URL QR codes

```txt
https://example.com/sale?utm_source=poster&utm_medium=qr&utm_campaign=spring
```

Use HTTPS — modern phones flag plain HTTP and some browsers warn the user. Keep query strings short and stable. If you need per-location tracking, use a different URL per placement rather than appending more parameters to one bloated string. Generate one with the [URL-to-PNG generator](https://fast-qr.app/static/url-to-png) or scalable [URL-to-SVG version](https://fast-qr.app/static/url-to-svg).

### Wi-Fi QR codes

```txt
WIFI:T:WPA;S:MyGuestNetwork;P:my-guest-password;H:false;;
```

The fields are:

- **`T`** — encryption type: `WPA`, `WEP`, or `nopass`.
- **`S`** — SSID, the network name.
- **`P`** — the password.
- **`H`** — whether the network is hidden, `true` or `false`.

Special characters in the SSID or password (semicolons, colons, commas, backslashes) need escaping with a backslash. Generate one with the [Wi-Fi-to-PNG generator](https://fast-qr.app/static/wifi-to-png) and avoid the typo problem. For deployment tips, see [QR code Wi-Fi best practices](https://fast-qr.app/learn/qr-code-wifi-best-practices).

### Phone tap-to-call

```txt
tel:+14155552671
```

Always use full international format with the country code and a leading plus sign. The [phone-to-PNG generator](https://fast-qr.app/static/phone-to-png) handles the formatting.

### SMS with pre-filled message

```txt
sms:+14155552671?body=Hi%20I%20need%20help%20with%20my%20order
```

The body has to be URL-encoded — spaces become `%20`, newlines become `%0A`. The [SMS-to-PNG generator](https://fast-qr.app/static/sms-to-png) handles encoding automatically.

### Email mailto

```txt
mailto:sales@example.com?subject=Quote%20request&body=Hi%20team%2C%20I%20need%20pricing%20for...
```

Same URL-encoding rules as SMS. Useful for "request a quote" buttons on print collateral. Build one with the [email-to-PNG generator](https://fast-qr.app/static/email-to-png). For a side-by-side gallery of every common payload type including WhatsApp, vCard, payment, and event check-in formats, see [QR code examples](https://fast-qr.app/learn/qr-code-examples).

### Plain text

```txt
Wi-Fi password: ask staff for the code (do not print passwords in public areas)
```

Plain text is fine for internal operations or back-of-house notes. For public signage it usually creates friction because the user still has to act on the message manually.

## Why some codes fail in the real world

Codes that pass tests in the office sometimes fail on actual signage. The cause is rarely the encoder. It's the environment around the printed code:

- **Too small for the scan distance.** A code printed at 1.5 cm is fine on a business card and useless on a wall poster six feet from the viewer. Module size needs to be roughly 1/10th of the scan distance for reliable reads.
- **No quiet zone.** When the code abuts a colored border or body copy, the scanner can't isolate the pattern.
- **Low contrast.** Pale gray on cream looks elegant in the brand guide and disappears under glare.
- **Glossy reflections.** Laminated menus and acrylic signs catch overhead light and wash out modules.
- **Motion blur.** Anyone scanning while walking past gets blurred frames the camera throws away.
- **Oversized logos.** A logo covering more than ~20% of the data area exceeds error correction capacity and the decode fails.
- **Bad printing.** Cheap inkjet printers smear modules. Always test the actual printed output, not the digital file.

A QR code that scans flawlessly on your monitor at arm's length might still fail on a shop window at night, or on a menu under warm tungsten lighting at a corner table. Test the code where customers will actually use it.

## What makes a code scan fast

The codes that scan in under half a second tend to share these properties:

- **Large, crisp modules.** Generous physical size, sharp edges, no compression artifacts.
- **Strong contrast.** Pure black on pure white is the gold standard. Colored codes are fine if the color is dark enough.
- **Clean quiet zone.** Four modules minimum, more if design space allows.
- **Minimal distortion.** Flat surface beats curved every time.
- **Short payload.** A lower QR version means fewer, bigger modules. Trim the URL.

This is why the most reliable QR codes look boring. The flashy ones with rounded modules, gradients, and full-bleed backgrounds usually scan just slowly enough that some users give up. For a print-ready checklist, see the [print-ready QR code checklist](https://fast-qr.app/blog/print-ready-qr-code-checklist).


For a side-by-side view of one-dimensional and two-dimensional labels, see [QR codes versus barcodes](https://fast-qr.app/learn/qr-code-vs-barcode). The [benefits guide](https://fast-qr.app/learn/qr-code-benefits) connects the encoding mechanism to practical uses.

## Sources

- [Wikipedia — QR code (Encoding)](https://en.wikipedia.org/wiki/QR_code#Encoding) — Module structure, finder/timing/alignment patterns, and encoding modes.
- [Denso Wave — How a QR Code is structured](https://www.qrcode.com/en/about/) — Original technical reference from Denso Wave.
- [ISO/IEC 18004:2015](https://www.iso.org/standard/62021.html) — Formal specification of QR module geometry and decoding procedure.

## Frequently asked questions

### How does a phone scan and decode a QR code?

The phone camera captures frames and looks for the three finder-pattern squares. Once detected, it corrects perspective distortion, samples each module in the grid, applies Reed–Solomon error correction to repair any damaged data, and then parses the payload (URL, Wi-Fi string, phone number, etc.) to present the appropriate action.

### Why can QR codes still be scanned when part of the code is damaged?

QR codes include redundancy data calculated with Reed–Solomon error correction. Depending on the error correction level chosen (L, M, Q, or H), a code can recover even if 7% to 30% of its modules are damaged or obscured, which is why placing a small logo in the center often still works.

### What is the difference between a URL QR code and a Wi-Fi QR code?

A URL QR code encodes a plain HTTPS link (e.g. https://example.com) and opens a browser when scanned. A Wi-Fi QR code encodes a special WIFI: string containing the network name, password, and encryption type, which prompts the phone to join the network directly without typing credentials.
