Skip to main content

Технічний посібник · ISO/IEC 18004

Як генеруються QR-коди? Повне пояснення процесу кодування

Генерування QR-коду — це пряме застосування кодування ISO/IEC 18004: URL, текст або корисне навантаження перетворюються на квадратну матрицю модулів ще до сканування. У цьому посібнику 2026 року описано лише конвеєр створення символу — від вибору режиму даних до остаточного експорту.

Як генеруються QR-коди?

QR-коди генеруються шляхом кодування вхідних даних у бітовий потік, додавання кодових слів виправлення помилок Reed-Solomon, розміщення бітів у квадратній матриці модулів, застосування оптимальної маски та вставлення відомостей про формат і версію разом з обов’язковою тихою зоною. Сумісний генератор QR автоматизує цей конвеєр ISO/IEC 18004 і створює сканований чорно-білий символ.

Що означає генерувати QR-код?

Генерування QR-коду означає створення символу, що зберігає корисне навантаження. Це не те саме, що сканування, яке декодує символ, або керування динамічним перенаправленням після появи символу.

A QR code is a two-dimensional barcode symbology. Its black and white squares are modules, and their arrangement carries both payload data and the instructions a scanner needs to interpret it.

A QR generator analyzes input and applies the ISO/IEC 18004 rules for capacity, structure, and error correction. A scanner performs the reverse operation; for that decoding flow, see how QR codes work.

A static QR code stores its final payload in the symbol. A dynamic QR code stores a redirect URL in the same kind of symbol, while its editable destination and later analytics live outside the encoding process.

Що таке конвеєр генерування QR-коду?

Процес генерування QR-коду має десять детермінованих етапів: аналіз введення, кодування, виправлення помилок, структурування повідомлення, побудова матриці, розміщення бітів, вибір маски, вставлення інформації про формат і версію, додавання тихої зони та експорт.

Цей конвеєр придатний для оцінювання QR-бібліотеки або розуміння того, що робить генератор під час обробки URL.

  1. 1

    Analyze input and choose a data mode

    The generator selects numeric, alphanumeric, byte, or Kanji encoding from the characters in the payload.

  2. 2

    Encode data into codewords

    Mode and character-count indicators, payload bits, a terminator, and padding are formed into eight-bit codewords.

  3. 3

    Generate error correction

    Reed-Solomon arithmetic creates redundant codewords for the selected recovery level.

  4. 4

    Structure the final message

    Data and error-correction blocks are interleaved in the order required by the selected version and level.

  5. 5

    Construct the matrix

    The generator chooses a QR version and reserves finder, timing, alignment, and information areas.

  6. 6

    Place data bits

    Codeword bits travel through remaining modules in a vertical zigzag pattern, with remainder bits where required.

  7. 7

    Evaluate mask patterns

    All eight XOR masks are scored to avoid patterns that are difficult for cameras to distinguish.

  8. 8

    Insert format and version information

    The chosen error-correction level and mask are BCH-protected; versions 7 and above also receive version information.

  9. 9

    Add the quiet zone

    A clear border at least four modules wide separates the symbol from neighboring artwork.

  10. 10

    Export and validate

    The finished matrix can be rendered as PNG, SVG, PDF, or EPS and tested at its intended print size.

Створити безкоштовний QR-код після перегляду процесу

Крок 1: як генератор вибирає режим даних QR-коду?

Вибирайте режим даних за набором символів, а не за назвою типу навантаження. Числові дані пакуються найщільніше, тоді як URL і рядки WiFi зазвичай потребують байтового режиму через малі літери та пунктуацію.

A data mode is the rule set used to convert characters into bits. A URL such as https://example.com commonly uses byte mode; a WiFi payload string also commonly uses byte mode, but has a different payload structure. See types of QR codes for format-selection guidance.

РежимНабір символівНайкраще для
Numeric0–9Phone numbers, numeric IDs, and digits-only payloads
Alphanumeric0–9, A–Z, space, $ % * + - . / :Uppercase coupon codes and simple identifiers
ByteISO 8859-1 or arbitrary byte sequencesURLs, email, WiFi strings, mixed-case and UTF-8 text
KanjiShift JIS double-byte charactersEligible Japanese text
Переглянути типи QR-кодів

Step 2: How is data encoded into codewords?

Encoding converts the selected mode, character count, and payload into bits, then adds a terminator and pad bytes until the selected version's data capacity is filled.

A codeword is an eight-bit unit of either encoded payload data or error-correction information. The mode indicator tells the decoder how to read the following bits, and the character-count indicator tells it how much data follows.

Payload length and error-correction level determine the smallest QR version with enough capacity. A longer URL or a higher recovery level can therefore increase the module count even when the visible design is unchanged.

Step 4: How is the QR matrix built?

A QR matrix is the square grid of modules that holds fixed patterns, data modules, and error-correction modules. Version 1 contains 21×21 modules, and each higher version adds four modules per side.

Finder patterns are the three 7×7 corner markers that help a scanner locate and orient the code. Timing patterns synchronize the module grid, while alignment patterns improve geometric correction on larger versions.

The generator reserves areas for format information and, from Version 7 onward, version information before placing data. Version 40 reaches 177×177 modules.

Step 5: How are codewords placed in modules?

After fixed patterns are reserved, the generator places data and error-correction bits in paired columns that zigzag from the lower-right toward the upper-left of the matrix.

Each bit becomes one light or dark module after masking. Reserved function modules are skipped, and remainder bits fill any capacity that is not represented by a full codeword.

This placement rule is why a QR symbol is a structured matrix rather than a visual hash: every position has a prescribed role.

Step 6: What are QR code mask patterns?

Mask patterns are eight XOR templates applied to data modules to break up large uniform regions and repeated patterns that can make camera detection less reliable.

The generator evaluates all eight masks and assigns penalty points for undesirable runs, blocks, and balance. It uses the lowest-penalty result and records the selected mask in format information.

Masking changes the visual distribution of modules, not the underlying payload. The scanner reads the mask identifier and reverses the operation during decoding.

Step 7: What are format and version information?

Format information tells a scanner the error-correction level and selected mask; version information identifies versions 7 through 40. Both use BCH protection for reliable reading.

Format information is duplicated near the finder patterns because it is needed early in decoding. Version information is placed in reserved areas on larger symbols.

These fields are part of symbol generation, so a code that merely resembles a QR image is not necessarily a valid QR symbol.

Step 8: Why does the quiet zone matter in final output?

The quiet zone is a mandatory clear border of at least four modules on every side. It lets scanners distinguish finder patterns from surrounding text, artwork, and borders.

PNG is useful for fixed pixel output, while SVG, PDF, and EPS preserve vector edges for large-format printing. Raster scaling can blur individual modules, so print resolution must preserve a readable module size.

Use the QR code size guide for physical sizing rules; generation creates the symbol, while production choices determine how faithfully it is reproduced.

Static vs dynamic QR codes in the generation context

Both static and dynamic QR codes start with a generated symbol. A static symbol encodes its final payload, while a dynamic symbol encodes a redirect URL whose destination can be edited later.

The entity chain is encoding → symbol → optional redirect layer → editable URL → scan analytics. Analytics attach when a dynamic redirect is requested, not while the QR matrix is generated.

Read about static vs dynamic QR codes for the business decision, and see plans for dynamic features without assuming every generator exposes low-level version or mask controls.

What happens in a typical QR generator, including QR-Build?

A typical generator automates ISO/IEC 18004 encoding, then renders the finished symbol in the requested format. Design overlays such as color and logo treatments are applied after core symbol generation and must preserve contrast and capacity.

At QR-Build, we treat output validation as a production step: we review core symbol output and use cross-device scan tests on iPhone and Android before export. Compliant generators follow ISO/IEC 18004; implementation details and available controls vary, so verify them in vendor documentation.

Open-source libraries such as ZXing and qrcode.js implement the same core pipeline. Teams needing API-level evaluation can review our QR code generator for developers.

QR code generation vs QR code scanning

Generation encodes forward from data to modules; scanning decodes backward from modules to data. This page covers the forward pipeline only.

Understanding generation helps explain why quiet zones, module size, contrast, and error correction affect reliability. For the camera-detection and decoding sequence, read how QR codes work.

Крок 3: що таке виправлення помилок Reed-Solomon?

Reed-Solomon — це блоковий код виправлення помилок, що використовується в QR. Він додає надлишкові кодові слова перед розміщенням матриці, щоб сканер міг відновити дані, коли деякі модулі пошкоджено або закрито.

The percentages below are approximate recovery capacities commonly associated with each level; real results depend on where and how damage occurs. Higher correction reduces available data capacity for a given version and can require a larger symbol.

РівеньПриблизне відновленняТипове застосування
L~7%Clean digital displays with low damage risk
M~15%Common general-purpose default; confirm a generator's setting
Q~25%Outdoor placement or moderate wear
H~30%Logo overlays, heavy print, or harsher environments
Прочитати посібник з виправлення помилок QR

Схема вибору режиму даних і виправлення помилок

Вибирайте режим даних за дозволеними символами, а виправлення помилок — за фізичним ризиком та оформленням. Вищий рівень не завжди кращий, якщо він змушує модулі бути надто малими для остаточного друку.
СитуаціяРежим данихРівень ECПорада щодо виводу
Phone number onlyNumericMUse SVG for print
Uppercase coupon codeAlphanumericMTest contrast
URL or WiFi stringByteM; H with a logoPreserve quiet zone
Logo overlayUsually byteHIncrease final print size
Outdoor signUsually byteQ or HCheck the size guide
Campaign with URL changesByte + dynamic redirectMUse a redirect layer and scan analytics

Поширені помилки під час генерування QR-кодів

Більшість проблем зі скануванням спричиняють виробничі рішення навколо правильно згенерованого символу: обрізана тиха зона, недостатній контраст, замалі модулі або рівень відновлення, що не відповідає дизайну.

Cropping the quiet zone

Do not place a border, text, or artwork inside the required clear margin.

Using too little error correction for a logo

A logo obscures modules; compensate deliberately and test the final artwork.

Forcing the wrong character encoding

Mixed-case text and non-ASCII content often need byte-aware handling rather than an alphanumeric assumption.

Reducing contrast

Decorative colors can make module boundaries difficult for cameras to separate.

Shrinking a raster file too far

Blurred or merged pixels can destroy module geometry even when the source matrix was valid.

Trusting a QR-like image

A square pattern must include valid structure, information fields, and quiet zone to be spec-compliant.

Найкращі практики надійного генерування QR

Використовуйте генератор, що відповідає специфікації, зберігайте тиху зону в чотири модулі, узгоджуйте виправлення помилок із фізичними умовами та тестуйте остаточний експорт на кількох пристроях до масового виробництва.

Start with ISO/IEC 18004 output

Use a generator or library that documents standards-based QR encoding.

Match recovery to the environment

Factor in print wear, logo coverage, lighting, and expected viewing distance.

Keep the quiet zone intact

Treat the white border as part of the symbol, not as optional surrounding whitespace.

Test iOS and Android

Test the final printed or displayed asset, not only the source file on one screen.

Choose vector for large print

SVG, PDF, or EPS help preserve crisp module edges at larger dimensions.

Use dynamic QR codes for changing campaigns

An editable redirect destination avoids re-encoding when a campaign URL changes; scan analytics occur on that redirect layer.

Глосарій: терміни генерування QR-кодів

Ці визначення описують пов’язані частини одного процесу: режим даних створює кодові слова, кодові слова стають модулями, а модулі утворюють QR-символ, що регулюється ISO/IEC 18004.

Module

One black or white square cell in a QR matrix.

Codeword

An eight-bit unit of encoded data or error-correction information.

Data mode

The character-encoding scheme selected before payload bits are created.

Error correction level

The L, M, Q, or H setting that controls redundant Reed-Solomon codewords.

Mask pattern

One of eight XOR templates used to improve module distribution.

Quiet zone

The required clear border of at least four modules around a QR symbol.

Finder pattern

One of the three large corner patterns that supports detection and orientation.

Alignment pattern

A smaller reference pattern that helps correct distortion in larger versions.

Timing pattern

Alternating modules that help synchronize the scanner to the grid.

Version

The QR size tier; Version 1 is 21×21 modules and each step adds four modules per side.

Format information

BCH-protected data identifying the error-correction level and selected mask.

Reed-Solomon

The error-correction algorithm that adds recoverable redundancy to QR codewords.

Static QR code

A symbol whose encoded payload remains fixed after creation.

Dynamic QR code

A symbol that encodes a redirect URL while its destination remains editable behind that redirect.

Related QR code resources

Поширені запитання

Ці відповіді стосуються генерування символів QR-кодів, а не окремого посібника зі сканування чи таксономії форматів QR.

How are QR codes generated?

QR codes are generated by encoding input into bits, adding Reed-Solomon error correction codewords, placing data in a module matrix, applying a mask, inserting format and version information, and adding a quiet zone under ISO/IEC 18004.

What algorithm is used to generate QR codes?

QR generation follows ISO/IEC 18004. Its core algorithm includes data-mode selection, bit encoding, Reed-Solomon error correction, zigzag matrix placement, mask scoring, and format-information insertion.

How does a QR code generator turn a URL into a QR code?

A generator typically encodes an https URL in byte mode, selects a version from data length and error-correction level, constructs the module matrix, selects a mask, and exports the finished symbol.

What are QR code data modes?

Numeric, alphanumeric, byte, and Kanji modes define how characters convert to bits. Numeric is compact for digits, while byte mode handles URLs, mixed-case text, and arbitrary byte data.

When should I use byte mode versus alphanumeric mode?

Use byte mode for URLs, lowercase text, and special characters. Use alphanumeric mode only when the payload stays within its uppercase letters, digits, space, and limited-symbol set.

What is Reed-Solomon error correction in QR codes?

Reed-Solomon adds redundant codewords so a scanner can recover data when modules are damaged. Increasing from L through H generally increases recovery capacity while reducing data capacity for a version.

What are QR code mask patterns?

Eight mask patterns XOR with data modules to prevent large uniform regions and repeated structures. The generator scores each result and selects the lowest-penalty mask.

How many modules are in a QR code?

Module count depends on version. Version 1 is 21×21 modules, each version adds four modules per side, and Version 40 is 177×177 modules.

How is QR code version determined?

A generator selects the smallest version that fits the payload under the chosen data mode and error-correction level. More data or higher recovery requires more capacity.

Does generating a QR code require an internet connection?

No. Generation is local computation. Internet is only needed to use a cloud service or to access content at a URL encoded in the finished symbol.

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

Generation creates a digital symbol; printing reproduces it on a physical surface. Final scan reliability depends on contrast, module size, quiet-zone preservation, and print quality.

Can I change a QR code after it is generated?

A static QR code has fixed encoded data. A dynamic QR code can keep its symbol while changing the destination behind its redirect URL; visual changes still require a safe re-export.

What is a quiet zone and why does it matter?

The quiet zone is a clear border of at least four modules around a QR symbol. Cropping it can prevent scanners from finding the symbol reliably.

What happens when you click Generate in QR-Build?

QR-Build processes the supplied content through the QR encoding pipeline, applies optional design treatments, and exports a scannable symbol. Dynamic QR workflows also register a redirect URL for later editing and analytics.

Готові перетворити дані на QR-код?

Використовуйте QR-Build для створення QR-символу на основі стандартів, а потім перевірте його в середовищі, де його скануватимуть люди.

Створити QR-код за допомогою QR-Build
QR Code - QR-Build

Створіть свій QR-код

Створити QR-код