Qraft

Codeword

A codeword is the fundamental data unit inside a QR code - a fixed-length block of 8 bits (1 byte). After input data is converted to a bit stream according to the encoding mode, it is divided into 8-bit segments to form data codewords. Reed-Solomon error correction codewords are then calculated and appended, and the complete sequence is arranged into the module pattern.

The total number of codewords is determined by the QR code's version (size) and error correction level. For example, Version 1 (21×21 modules) at error correction level L has 26 total codewords: 19 for data and 7 for error correction. Version 40 (177×177 modules) at level L reaches 3,706 total codewords.

Understanding codewords explains why raising the error correction level reduces data capacity. The total codeword count stays the same, but a larger proportion is allocated to error correction, leaving fewer codewords for actual data. This knowledge helps optimize the balance between QR code size and data volume.