
EAN-13 Barcode Math: Check Digits, Parity, and Japan's JAN Codes
A retail barcode does more than encode digits as lines of different widths. EAN-13—the symbol used for Japan's standard-length JAN (Japanese Article Number) codes—combines a check digit with patterns that can be decoded in either direction. The GTIN (Global Trade Item Number) is the identifying number; the barcode is its machine-readable representation. A valid check digit does not prove that a number has been officially assigned or that a product is authentic. This guide separates the arithmetic, symbol structure, and assignment rules.
Japanese original published: 2026-05-05
From an early patent to the first retail UPC scan
Norman Joseph Woodland and Bernard Silver's 1952 US patent, Classifying Apparatus and Method, describes parallel-line and concentric-circle code examples. Those designs were predecessors, not the later UPC standard.
In 1973, the US grocery industry adopted the Universal Product Code. George Laurer at IBM designed UPC-A, which represents a 12-digit number. On June 26, 1974, a pack of Wrigley's Juicy Fruit gum was scanned at a Marsh supermarket in Troy, Ohio. This is the celebrated first retail checkout scan of a UPC product barcode, rather than a claim that no experimental barcode had ever been read before.
EAN extended the international numbering system while retaining compatibility with UPC. In Japan, JAN numbers have a 13-digit standard form and an 8-digit short form, represented by EAN-13 and EAN-8 respectively. This article focuses on the 13-digit form within the GS1 system.
What the 13 digits mean—and what they do not
A GTIN-13 built using a GS1 Company Prefix combines that prefix, an item reference, and a check digit. The prefix length varies, so you cannot split every number into a company and a product using the same fixed positions.
Scroll horizontally if the table does not fit.
| Positions from the left | Length | Role | Worked example |
|---|---|---|---|
| 1–12 | 12 digits | GS1 Company Prefix + item reference | 490123456789 |
| 13 | 1 digit | Check digit | 4 |
The example is for arithmetic only: it is not a grant to use the number, nor a claim that it is unassigned. Special systems such as ISBN and restricted-circulation numbers should not all be interpreted using this ordinary company-prefix breakdown.
GS1 prefixes 450–459 and 490–499 are allocated to GS1 Japan. They do not identify the country where a product was manufactured. Prefix allocation identifies the GS1 numbering organisation, while production may take place elsewhere.
Under Japan's system, GS1 Japan licenses company prefixes of 7, 9, or 10 digits. The item reference fills out the first 12 digits, and the final check digit completes the GTIN-13. These are Japan's assignment arrangements, not a description of every country's registration process.
Calculating the check digit: alternating weights of 1 and 3
Starting at the left of the 12-digit payload, multiply digits in positions 1, 3, 5, and so on by 1. Multiply those in positions 2, 4, 6, and so on by 3. Add the products, take the remainder modulo 10, then calculate (10 − remainder) mod 10.
For the payload 490123456789:
Weight 1: 4 + 0 + 2 + 4 + 6 + 8 = 24
Weight 3: 9 + 1 + 3 + 5 + 7 + 9 = 34; 34 × 3 = 102
Weighted sum: 24 + 102 = 126
Remainder: 126 mod 10 = 6
Check digit: (10 − 6) mod 10 = 4
The check catches many adjacent-digit swaps. For example, exchanging 48 and 84 changes the weighted sum by a value that is not a multiple of 10. But swapping adjacent digits that differ by 5 is not detected: 0↔5, 1↔6, 2↔7, 3↔8, and 4↔9. Both 4901234567894 and 9401234567894 pass the check.
If exactly one digit of a valid, fixed-length 13-digit number is replaced by a different decimal digit, the check always detects it, including a change to the check digit itself. This is error detection, not error correction. It does not detect every multiple-digit change, and it cannot authenticate a product.
This runnable JavaScript example takes exactly 12 ASCII digits and returns the check digit. Keep identifiers as strings so leading zeros are preserved.
function ean13CheckDigit(payload) {
if (typeof payload !== "string" || !/^[0-9]{12}$/.test(payload)) {
throw new TypeError("Expected exactly 12 ASCII digits");
}
const sum = [...payload].reduce(
(total, digit, index) => total + Number(digit) * (index % 2 === 0 ? 1 : 3),
0
);
return String((10 - sum % 10) % 10);
}
console.log(ean13CheckDigit("490123456789")); // "4"
Checking arithmetic, assigning a legitimate product number, and verifying a printed symbol are separate tasks. NanToo's Japanese barcode generator does not verify assignment or authenticity. Its ITF-14 output is a simplified symbol without bearer bars, not a guarantee of compliance for commercial printing.
Inside the symbol: modules, quiet zones, and parity
A module is the smallest unit of width. EAN-13 directly encodes 12 digits as seven-module characters; the leading digit is represented by a pattern choice, explained below. Here, 1 means a dark module and 0 a light module.
Scroll horizontally if the table does not fit.
| Region | Width in modules | Purpose |
|---|---|---|
| Left quiet zone | At least 11 | Clear space before the symbol |
| Left guard | 3: 101 | Symbol boundary |
| Six left-hand characters | 42 | 6 × 7 modules |
| Centre guard | 5: 01010 | Separates the halves |
| Six right-hand characters | 42 | 6 × 7 modules |
| Right guard | 3: 101 | Symbol boundary |
| Right quiet zone | At least 7 | Clear space after the symbol |
Source for the table: GS1 General Specifications Release 26.0, §§5.2.3.4–5 and 5.2.6.3. The symbol has 95 modules excluding quiet zones, or 113 including the minimum quiet zones. If one module has physical width X, the left and right clear spaces must be at least 11X and 7X. This horizontal layout does not replace requirements for X-dimension, bar height, contrast, or print quality.
Digits use three encoding sets, often called L, G, and R. These correspond to GS1 sets A, B, and C. Parity refers to the odd or even number of dark modules in a character—not whether the digit itself is odd or even.
- L / set A: odd parity; used on the left, starting with a light module.
- G / set B: even parity; also used on the left, starting with a light module.
- R / set C: used on the right; the dark/light complement of L.
For digit 0, L is 0001101, G is 0100111, and R is 1110010. R is the dark/light complement of L; G is R read in reverse.
The first digit has no separate seven-module character. Instead, it selects the L/G sequence for the six left-hand characters. A leading 4 selects LGLLGG; a leading 0 selects LLLLLL. Leading 0 is reserved for representing GTIN-12, preserving UPC compatibility.
Why the barcode can be decoded in either direction
EAN/UPC is designed for decoding from either direction. That still requires a scan crossing the bars, adequate clear space and print quality, and suitable equipment. It is not a promise that every scanner will read a damaged symbol at any angle.
- Symmetric guards: the outer guards are both 101, and the centre guard is 01010. They retain their patterns when read in reverse.
- Encoding sets and order: reading an R character backwards produces a G pattern. Because the left side may contain both L and G, a single character's parity cannot identify direction on its own. The guard positions, allowed pattern combinations, digit count, and check digit are considered together.
- Recovering the sequence: the decoder interprets the symbol structure and reconstructs the digit order appropriate to the scanning direction.
This describes the structure that makes reverse decoding possible, rather than prescribing the implementation of every scanner.
EAN-8, UPC-A, and other barcode formats
Different formats serve different applications:
Scroll horizontally if the table does not fit.
| Format | Data length | Typical role and limitations |
|---|---|---|
| EAN-8 | 8 digits | Small products with limited label space. GTIN-8 uses its own assignment arrangements; it is not a truncated GTIN-13. Japan has both one-off keys and assignment through a short-form company prefix. |
| UPC-A | 12 digits | Widely used in North America. Prefixing a GTIN-12 with 0 gives its 13-digit representation. An arbitrary GTIN-13 cannot be shortened to UPC-A. |
| Code 128 | Variable | Letters, digits, and symbols for business and logistics labels. |
| Code 39 | Variable | Uppercase letters, digits, and selected symbols for business applications. |
| ITF-14 | 14 digits | GTIN-14 on cases and other groupings. Suitable for corrugated packaging, but bearer-bar and print-quality requirements still apply. |
| Codabar / NW-7 | Variable | Digits and selected symbols with start/stop letters A–D, used in existing systems such as libraries. |
EAN-13 carries a fixed 13-digit identifier. Code 128 is variable-length, but its symbol grows wider as data increases: label space, minimum bar width, and reading equipment impose practical limits. There is no universal limit of “a few dozen characters” for every application. Two-dimensional symbols such as QR Code and Data Matrix provide other ways to carry more data. See our guide to QR Code error correction for a different approach to handling damaged symbols.
The key distinctions to remember
- A typical company-prefix-based GTIN-13 combines a GS1 Company Prefix, an item reference, and a check digit. The number and its EAN-13 symbol are distinct.
- Alternating weights of 1 and 3 detect every single decimal-digit substitution in a valid fixed-length number, but adjacent swaps with a difference of 5 pass undetected.
- Twelve seven-module characters plus guards occupy 95 modules. With minimum quiet zones, the width is 113 modules.
- The leading digit is encoded by the L/G pattern of the left half, not by an extra seven-module character.
- The symbol structure supports decoding in either direction; actual reading still depends on scanning and printing conditions.
- UPC was adopted in 1973, and the first celebrated retail checkout scan followed in 1974. GS1 now maintains the international identification system.
References and sources
- GS1 Historical Timeline ↗
- GS1 General Specifications (Release 26.0, Jan 2026), §§5.2, 5.3, 7.9 ↗
- ISO/IEC 15420:2025 — EAN/UPC bar code symbology specification ↗
- Woodland, N.J. & Silver, B. (1952). US Patent 2,612,994 — Classifying Apparatus and Method ↗
- GS1 Japan — GS1 Company Prefixes and GTIN (JAN) codes (Japanese) ↗
Editorial note
This article was prepared with AI assistance and reviewed by an editor before publication. It may still contain factual errors, interpretation mistakes, or outdated information. Check the cited primary sources or official documentation before making an important decision.

