The four data compaction schemes in QR codes — numeric, alphanumeric, byte, and kanji — each with a 4-bit mode indicator and a packing method tuned to its character set.
QR codes do not store text as plain bytes. Before any error correction or masking, the payload is compacted using one of four encoding modes, each designed for a different kind of data. The mode is announced by a 4-bit mode indicator at the start of the bit stream, followed by a character count indicator whose length depends on the symbol version, followed by the compacted data bits.
Numeric mode (0001): digits only
Numeric mode encodes the characters 0–9 at maximum density: every group of three digits is packed into 10 bits, a leftover pair into 7 bits, and a single leftover digit into 4 bits. Three decimal digits carry about 9.97 bits of information, so 10 bits per triplet is nearly optimal. This mode exists because so many real-world QR payloads are digit strings — phone numbers, serial numbers, IDs, amounts — and the density gain over byte mode is roughly 3.3×. If your payload is purely numeric, a good generator selects this mode automatically.
Alphanumeric mode (0010): a 45-character set
Alphanumeric mode supports 45 characters: digits 0–9, uppercase A–Z, space, and the symbols $ % * + − . / :. Pairs of characters are packed into 11 bits (45 × 45 = 2025 combinations fits in 11 bits), with a single trailing character taking 6 bits. This is the classic mode for URLs in uppercase, WiFi credentials without special characters, and industrial identifiers. Note the case restriction: lowercase letters are not in the set, so "https://Example.com" cannot use pure alphanumeric mode — the lowercase letters force a switch to byte mode.
Byte mode (0100): 8-bit data
Byte mode stores raw 8-bit bytes, interpreted by default as ISO-8859-1 (Latin-1). This is the universal fallback: URLs with lowercase letters, UTF-8 text, and binary data all travel in byte mode. Modern practice pairs byte mode with an ECI designator for UTF-8, which is how QR codes carry Arabic, Urdu, Chinese, emoji, and other non-Latin text. Byte mode is the least dense for digit-heavy data but the most general.
Kanji mode (1000): Shift JIS efficiency
Kanji mode compacts characters from the Shift JIS encoding (the Japanese standard) at 13 bits per character, covering the JIS X 0208 character set. Each character's two Shift JIS bytes are combined into a 13-bit value. This mode is a legacy of QR's Japanese origins and remains relevant for Japanese-language payloads, though UTF-8 byte mode has largely superseded it for new applications.
Mixed modes and the character count indicator
A single QR symbol can chain multiple segments in different modes — for example, a numeric segment for a phone number followed by a byte segment for a name — each with its own mode indicator and count. The character count indicator that follows each mode indicator is 10, 12, or 14 bits for numeric mode (and correspondingly shorter for other modes) depending on whether the version is 1–9, 10–26, or 27–40, because larger versions need wider counters. Sophisticated encoders analyze the payload and choose the optimal segmentation automatically; the difference between naive all-byte encoding and optimal mixed-mode encoding can change the required version for long payloads.
Diagram description: Bit-stream diagram showing mode indicator, character count indicator, and data bits for the same digit string encoded in numeric mode versus byte mode, with the bit-count savings labeled.
