Skip to main content

完整指南 · 2026

二维码如何工作?扫描、解码以及后续流程

二维码通过智能手机相机扫描,将印刷或屏幕上的图案转化为数字操作。本指南说明二维码如何工作,涵盖图像捕获、载荷和目标位置;如需先了解定义,请阅读什么是二维码

二维码如何工作?

二维码将数据存储在由黑白模块组成的二维图案中。智能手机相机会定位角落的定位图形,读取模块,应用纠错,提取载荷,并触发操作,例如打开网站、加入 WiFi、保存联系人或发起付款。动态二维码会增加重定向层,因此可以在印刷后更改目标位置并记录扫描分析。

二维码如何逐步工作?

扫描遵循从扫描到操作的流程:捕获图像、找到代码、校正形状、读取模块、恢复数据、提取载荷,然后交给合适的应用。动态二维码会在本地解码后增加重定向请求。

二维码是 Quick Response 二维条码。以下八个阶段描述面向用户的解码过程,它与编码过程相反。

  1. 1

    Point the camera

    A phone camera or QR reader captures the code in a live image frame.

  2. 2

    Detect finder patterns

    The scanner recognizes the three large corner squares and identifies a possible QR symbol.

  3. 3

    Correct orientation and perspective

    Software compensates for rotation, distance, and a code photographed at an angle.

  4. 4

    Read the module grid

    Each black or white module is interpreted as part of a binary data pattern.

  5. 5

    Apply error correction

    Reed-Solomon redundancy helps recover data from partial damage, dirt, or imperfect capture.

  6. 6

    Extract the payload

    The decoder reconstructs a URL, text string, vCard, WiFi credentials, or another supported payload.

  7. 7

    Trigger the device action

    The operating system offers the appropriate browser, Settings, Contacts, or payment-app action.

  8. 8

    Resolve a dynamic destination

    For a dynamic QR code, a short redirect URL reaches a server that forwards to the current destination and can log the scan.

1

相机

2

定位图形

3

解码

4

载荷

5

操作

从扫描到操作的流程:相机 → 定位图形 → 模块 → 解码 → 载荷 → 操作。

What happens when you scan a QR code?

Your camera captures an image, the operating system or scanner app detects and orients the code, decodes its data, and presents an action prompt. In good lighting with clear contrast, this often feels nearly immediate.

The camera first needs enough contrast to distinguish the dark modules from the light background. Glare, motion blur, shadows, and a code that is too small can slow or prevent detection.

In the background, the scanner searches for the finder-pattern geometry, samples the module grid, and decodes the payload. On screen, you usually see a preview banner before the phone opens a browser, Settings, Contacts, or another handler.

The name Quick Response refers to the format's practical ability to be found and decoded rapidly, not to a guarantee that every web destination loads quickly.

What the camera sees

A perspective-distorted square image with light and dark regions.

What software does

It locates structure, estimates the grid, and reconstructs the encoded payload.

What you see

A contextual prompt that lets you review and continue to the destination.

How does a phone read a QR code?

Built-in camera software searches for the three finder patterns, uses timing and alignment patterns to establish the module grid, and reads black and white modules as data. Error correction helps rebuild the payload when a capture is imperfect.

Most modern smartphones scan QR codes without a dedicated app. Apple's Camera app and Google Lens are widely reliable; a dedicated reader can still help with specialized workflows, saved history, or older devices.

A finder pattern is one of the three large corner squares that lets a scanner orient the symbol. Alignment patterns are smaller reference squares used on larger codes, while timing patterns are alternating modules that keep the scanner aligned to rows and columns.

The quiet zone is the blank margin around the QR code. It separates the symbol from nearby text or artwork, so cropping it can make finder-pattern detection unreliable.

Module

An individual black or white square in the QR matrix; together, modules represent the encoded data.

Finder pattern

A corner marker that helps the camera locate and orient the code.

Quiet zone

The clear border around the symbol that helps a scanner distinguish it from its surroundings.

How is data stored in a QR code?

Data is stored as a bit sequence mapped onto black and white modules in a square matrix. The decoded payload can be a URL, text, vCard contact, WiFi credentials, or another standardized format.

A QR code stores more information than a one-dimensional barcode because it uses a two-dimensional matrix. Capacity depends on the symbol size, payload content, and error-correction setting.

A restaurant menu commonly carries a URL; a business card can carry a vCard; and a hotel WiFi code can carry a network string. See types of QR codes for payload-selection guidance and how QR codes are generated for the forward encoding process.

How does QR code decoding work?

Decoding reverses generation: the scanner reads symbol metadata and modules, uses Reed-Solomon error correction to recover codewords, and outputs the payload. Generating encodes data into a matrix; scanning decodes it back out.

A decoder reads format and version information before interpreting the data region. ISO/IEC 18004 defines the QR format; scanners use its structural rules instead of treating the image as an arbitrary visual pattern.

Reed-Solomon is the error-correction method that adds recoverable redundancy. It is why a scratched code can still scan, although recovery depends on the correction level and where the damage occurs. Read about QR code error correction for level details.

Decode-side mechanics should not be confused with generation. Generation moves forward from payload to symbol; decoding moves backward from modules to payload.

How do static QR codes work?

A static QR code contains its final payload directly in the symbol: scan, decode, and act. Because there is no redirect layer, changing the destination requires a new QR code and a new print or display.

Static QR codes suit fixed information such as permanent WiFi credentials, a vCard, plain text, or a long-lived PDF URL. The device acts on the decoded payload immediately.

Their simplicity is a strength when the payload is truly permanent. They cannot replace a printed code's destination after the code has been distributed.

How do QR codes work on iPhone and Android?

On iPhone, the Camera app typically displays a notification for a recognized QR code. On Android, the Camera app or Google Lens commonly shows a prompt; exact behavior varies by manufacturer and operating-system version.

On iPhone, aim the Camera app at the code and tap the notification banner. iOS also offers QR-related shortcuts and photo recognition features on supported versions.

On Android, point the Camera app or Google Lens at the code and tap the prompt. Test on your own devices because camera interfaces and permissions differ across manufacturers.

Camera permission is required for live scanning. A reader app is useful when a device's default camera does not expose QR detection or when a workflow needs additional controls.

Do QR codes need internet to work?

Decoding is local: a phone can read the pattern without internet. The action may need connectivity, such as opening a URL or resolving a dynamic redirect; plain text, vCard, and WiFi payloads can still be decoded offline.

This is the Decode vs Destination rule: decoding is always local, while the payload's destination may require a network. A menu URL can decode in a basement even if its web page cannot load there.

A dynamic QR code needs connectivity after decoding because the device must reach its redirect layer. Joining a local WiFi network may not need internet itself, though the network can provide it afterward.

How does QR code scanning differ from barcode scanning?

QR codes are 2D barcodes made from a matrix of modules, while traditional barcodes use one-dimensional lines. The QR layout supports more data and can be read from different orientations when the full structure is visible.

Both formats rely on optical contrast and a scanner that understands the symbol. Read the full QR code vs barcode comparison for format and use-case detail.

Are QR codes safe to scan?

QR codes are not inherently malicious; the risk comes from an unknown or deceptive destination. Preview the action when possible, scan trusted codes, and treat unexpected payment or login prompts carefully.

A QR image does not reveal its destination at a glance, so a sensible check is to inspect the domain before sharing information. Read QR code security for phishing, verification, and organizational guidance.

动态二维码如何工作?

静态二维码直接包含最终载荷,而动态二维码包含一个短重定向 URL。本地解码后,重定向服务器会转发到当前目标位置,并可记录扫描分析;印刷图案保持不变。

动态链路为:符号 → 重定向层 → 可编辑 URL → 扫描分析。

阶段静态二维码动态二维码
What is in the symbol?Final payload, such as a URL or vCard.A short redirect URL.
After decodeThe device opens the payload directly.The device reaches the redirect server first.
Destination changeA new QR code is required.Update the redirect target; the same printed code works.
Scan analyticsNo redirect-layer record is created.A redirect layer can log the scan.
Best fitPermanent WiFi, vCards, and fixed information.Campaigns, menus, events, and trackable links.

此比较说明成功扫描后的工作机制。购买前请核实服务商能力。

实际使用场景:二维码如何在实践中工作

相同的解码流程会根据载荷导向不同操作:URL 打开网页,vCard 提示保存联系人,WiFi 字符串打开网络设置,付款链接则交给付款应用处理。

Restaurant menu

A guest scans a printed code, decodes a menu URL, and opens a mobile-friendly menu page.

Event check-in

A code leads to registration details or ticket validation after the scanner extracts its URL or identifier.

Product packaging

A package code can open instructions, warranty information, or a current promotion.

Business card

A vCard payload decodes into contact data that the phone can offer to save.

Hotel WiFi

A WiFi payload passes network details to the phone so the guest does not type a password.

Payment

A payment payload opens the relevant app or checkout flow; settlement happens separately inside that service.

探索二维码示例

亲自试试:创建并测试二维码

理解从扫描到操作流程的最佳方式,是创建一个二维码,用自己的手机扫描,并在发布前确认目标位置。

Create a test code

Use a short URL, text, or WiFi payload and preserve a clear quiet zone.

Scan on two platforms

Test with iPhone Camera and Android Camera or Google Lens where available.

Verify the action

Confirm that the expected page, settings screen, contact card, or redirect opens correctly.

在 QR-Build,我们会在发布前通过 iPhone 和 Android 的跨设备扫描测试验证输出。

免费创建并测试二维码

生成静态或动态二维码,用手机扫描,并在印刷前确认目标位置。

免费创建二维码

常见二维码扫描问题的原因是什么?

大多数失败来自制作问题而非解码问题:尺寸或对比度不足、静区被裁切、反光、超出纠错能力的损坏,或目标页面不适合移动设备。

Code is too small or low contrast

Tiny modules or similar foreground and background colors prevent reliable detection.

Quiet zone is cropped

Keep the blank margin outside all four edges; do not let borders or copy crowd finder patterns.

Damage exceeds recovery capacity

Wrinkles, dirt, or a logo can cover too many modules for the selected correction level.

Glare or motion blur

Change the angle, improve lighting, or hold the camera still so module edges remain clear.

Destination is not mobile friendly

A successful scan can still disappoint if the page is slow, broken, or difficult to use on a phone.

A changed static URL

A static code cannot be retargeted; use a dynamic code when a campaign destination will change.

可靠二维码扫描的最佳实践

可靠扫描需要高对比度、足够的物理尺寸、完整静区、适合移动设备的目标位置,以及在 iPhone 和 Android 上进行测试。

Use high contrast

Dark modules on a light background remain the most dependable visual treatment.

Match size to scan distance

Choose a practical print size for the expected distance; use the QR code size guide.

Preserve the quiet zone

Keep the required blank margin clear in print, signage, and digital layouts.

Test real devices

Check iPhone and Android behavior before producing a large print run.

Write a nearby call to action

A prompt such as “Scan to view menu” explains why someone should scan.

Choose dynamic when change is expected

Dynamic redirects make evolving menus and campaigns easier to manage after printing.

二维码何时最适合商业使用?

当二维码容易被看见、容易扫描,并能连接到有用的移动操作时,效果最佳。固定载荷选静态码;目标会变或需要重定向层报告时选动态码。
情况建议原因
URL may change after printDynamic QR codeThe redirect layer can update the destination while the printed symbol remains the same.
Permanent guest WiFiStatic WiFi QR codeThe payload is fixed and can decode without a redirect server.
Marketing campaign with ROI trackingDynamic QR with analyticsScans can be logged at the redirect layer.
Business-card contactStatic vCard QR codeThe decoded contact can be offered for immediate saving.
Large outdoor printSize and error-correction testingDistance and wear make module clarity and recovery more important.
First deploymentTest iPhone and AndroidCross-device checks expose contrast, size, and destination issues early.

二维码工作原理术语表

这些术语描述一个相连的系统:扫描 → 定位图形 → 模块 → 解码 → 载荷 → 操作。

QR code

A Quick Response code: a two-dimensional barcode that smartphone cameras can scan.

Module

An individual black or white square in the QR matrix.

Finder pattern

One of three corner squares that helps scanners locate and orient the code.

Alignment pattern

A smaller reference pattern that helps correct perspective on larger QR codes.

Timing pattern

Alternating modules that synchronize the scanner to the row and column grid.

Quiet zone

The blank margin around a QR code required for reliable detection.

Payload

The decoded data, such as a URL, text string, vCard, or WiFi credentials.

Decode

The process of reading modules and recovering the payload from a QR symbol.

Error correction

Redundant data that helps scanners recover a payload from partial damage.

Static QR code

A QR code with a fixed payload baked directly into its symbol.

Dynamic QR code

A QR code that encodes a redirect URL with an editable destination behind it.

Redirect layer

A server-side URL that resolves to the current destination and can record scans.

常见问题

How do QR codes work?

A QR code stores data in black and white modules. A scanner detects finder patterns, reads modules, applies error correction, extracts the payload, and performs the linked action.

What happens when you scan a QR code?

Your camera captures the image, the scanner locates and orients the code, decodes the data, and shows an action prompt for a browser, Settings, Contacts, or a payment app.

How does a phone read a QR code?

Built-in camera software detects the three finder patterns, corrects for angle and distance, reads modules as bits, and reconstructs the payload with error correction.

How do QR codes work step by step?

Point the camera, capture the image, detect finder patterns, correct orientation, read modules, apply error correction, extract the payload, and trigger the action. Dynamic codes then resolve a redirect URL.

How do QR codes work without internet?

Decoding happens locally without internet. Opening a URL or resolving a dynamic redirect usually needs connectivity, while text, vCard, and WiFi payloads can be decoded offline.

How do dynamic QR codes work?

A dynamic QR code encodes a short redirect URL. The redirect server forwards to the current destination and can log scan analytics, so the destination can change without reprinting.

How do static QR codes work?

A static QR code contains the final payload directly in the symbol. It has no redirect layer, so changing its destination requires a new code.

How do QR codes work on iPhone?

Open the Camera app, point it at the QR code, and tap the notification banner that appears with the decoded action. Interface details vary by iOS version.

How do QR codes work on Android?

Most Android phones use the Camera app or Google Lens. Point at the code and tap the prompt; the exact interface varies by manufacturer and Android version.

How is data stored in a QR code?

Data is encoded as bits mapped onto black and white modules in a square matrix. Payloads can include URLs, text, contacts, WiFi credentials, and more; see types of QR codes.

Why do QR codes still scan when damaged?

Reed-Solomon error correction adds redundant data that can help recover a payload when some modules are scratched or dirty. The result depends on the correction level and damage pattern.

What is the difference between scanning and generating a QR code?

Generating encodes data into a symbol; scanning decodes the symbol back into data. Read how QR codes are generated for the forward process.

Can QR codes be dangerous?

QR codes themselves are not malicious, but they can point to phishing sites or unwanted actions. Scan trusted sources and preview destinations when possible; see QR code security.

How do QR codes work on a menu or for payments?

A menu QR usually opens a mobile web page. A payment QR opens a payment app or checkout flow; the transaction happens inside that service after decoding.

相关二维码指南

QR Code - QR-Build

免费创建二维码

数秒内测试扫描