The problem a check digit solves
A check digit is neither a hash nor encryption, it is a checksum: an extra value, computed from the digits before it through a public, reversible formula, whose only job is to confirm that sequence of numbers is internally consistent. If the difference between those three ideas still trips you up, the hashing, encryption and encoding guide settles it. A checksum hides nothing, protects nothing and does not prove a code is authentic or that the product exists: it only proves nobody fat-fingered a key typing it, or that a QR code reader and a barcode reader captured the right number.
This platform’s barcode generator produces four symbologies: Code 128, EAN-13, EAN-8 and UPC-A. The last three share the same checksum family, modulo 10 with weights 1 and 3, the core subject of this guide. Code 128 is different: each character becomes its own numeric code, and its check digit comes from a position-weighted sum, modulo 103, so it sits outside this guide’s scope. One detail only shows up in the tool’s own source: UPC-A has no separate formula of its own, it is generated by prefixing a "0" onto the 11 digits and reusing the exact EAN-13 function. That is not an implementation shortcut, it mirrors what the real standard says: a UPC-A is, structurally, an EAN-13 whose first digit always happens to be zero.
- Check digit
- The last digit of a code, computed from the ones before it by a fixed formula; it exists only to catch errors, it carries no information of its own about the product or book.
- Checksum
- The result of that calculation. "Matching the checksum" means the recomputed digit agrees with the one printed on the code.
- Symbology
- The drawing that turns digits into bars. EAN-13, UPC-A, EAN-8 and Code 128 are different symbologies; the check digit is math, not drawing.
- Modulo (modular arithmetic)
- The remainder of a division. "Modulo 10" looks at how much is missing to reach the next multiple of 10; "modulo 11" looks at the remainder after dividing by 11, including the special case where it comes out to exactly 10.
- GS1 prefix
- The first 3 digits of an EAN-13, assigned to whichever body issued the code, not to the country where the product was made. 789 and 790 identify GS1 Brasil.
EAN-13 and UPC-A: the modulo-10 checksum
The EAN-13 and UPC-A math is a weighted modulo-10 checksum, documented by GS1 itself, the body that administers these codes worldwide. Start at the rightmost data digit, the one right next to the check digit: it gets weight 3. The next one, to its left, gets weight 1. And so on, alternating 3, 1, 3, 1..., all the way to the very first digit on the left. Multiply each digit by its weight, add everything up, and the check digit is whatever number between 0 and 9 is missing to bring that sum to the next multiple of 10. That is exactly the math running inside this platform’s barcode generator, confirmed straight from the tool’s own source.
S = Σ (dᵢ × wᵢ) → CD = (10 − (S mod 10)) mod 10- dᵢ
- the i-th data digit (the EAN-13’s first 12, or UPC-A’s 11)
- wᵢ
- the weight for that position: 3 on the digit closest to the check digit, alternating to 1
- S
- the sum of all digit × weight products
- CD
- the check digit, always between 0 and 9
| Position | Digit | Weight | Product |
|---|---|---|---|
| 1st | 7 | 1 | 7 |
| 2nd | 8 | 3 | 24 |
| 3rd | 9 | 1 | 9 |
| 4th | 2 | 3 | 6 |
| 5th | 4 | 1 | 4 |
| 6th | 5 | 3 | 15 |
| 7th | 1 | 1 | 1 |
| 8th | 0 | 3 | 0 |
| 9th | 8 | 1 | 8 |
| 10th | 8 | 3 | 24 |
| 11th | 6 | 1 | 6 |
| 12th | 3 | 3 | 9 |
The twelve products add up to 113. The next multiple of 10 above 113 is 120; 120 minus 113 is 7. The check digit is 7, and the full EAN-13 reads 7892451088637. Note the 789 prefix: per GS1 Brasil, it (together with 790) marks codes it issued, not that the product was manufactured in Brazil, the two get conflated often.
UPC-A follows the same math over 11 data digits, one fewer than EAN-13. A quick example: 03600029145. With only 11 positions, the weight alternation already lands on 3 at the first position from the left (the rightmost digit still carries weight 3, the count just climbs from there). The sum is 58; the next multiple of 10 is 60; the check digit is 2, closing the code as 036000291452. That is why, in the barcode generator, generating a UPC-A and an EAN-13 runs exactly the same engine underneath, confirmed in the source: UPC-A gets a leading zero, becomes a 12-digit EAN-13, and the same function computes the check digit for both.
ISBN-10: the modulo-11 checksum and the letter X
ISBN was born apart from the retail barcode. The system began in the United Kingdom in 1967 and reached the United States in 1968, through R. R. Bowker. For decades an ISBN had 10 digits, 9 data digits plus 1 check digit, but the math behind it differs from EAN-13’s. Instead of modulo 10, ISBN-10 uses modulo 11, and the choice is not cosmetic: 11 is prime, which changes what the digit can prove, a point we return to in the final section. The weights change too: they descend from 10 to 2 across the 9 data digits, left to right. The check digit is whatever value between 0 and 10 makes the sum of all products a multiple of 11; when that value comes out to exactly 10, it does not fit a single digit, so the standard uses the letter X instead, the only position in an ISBN-10 that can ever be a letter.
S = Σ (dᵢ × pᵢ) → r = S mod 11 → DV = (11 − r) mod 11- dᵢ
- the i-th of the 9 data digits
- pᵢ
- the weight for that position, descending from 10 to 2, left to right
- r
- the remainder of the sum divided by 11
- DV
- the check digit; becomes the letter X when the result is 10
| Position | Digit | Weight | Product |
|---|---|---|---|
| 1st | 6 | 10 | 60 |
| 2nd | 5 | 9 | 45 |
| 3rd | 4 | 8 | 32 |
| 4th | 7 | 7 | 49 |
| 5th | 8 | 6 | 48 |
| 6th | 2 | 5 | 10 |
| 7th | 1 | 4 | 4 |
| 8th | 9 | 3 | 27 |
| 9th | 3 | 2 | 6 |
The nine products add up to 281. The remainder of 281 divided by 11 is 6 (281 = 25×11 + 6). The check digit is 11 minus that remainder, 5. The full ISBN-10 reads 6547821935. A second example shows the letter X in practice: for the base 650114924, the weighted sum is 188, and the remainder of 188 divided by 11 is 1 (188 = 17×11 + 1). Eleven minus one is ten, and ten does not fit a single digit, so the ISBN-10 closes as 650114924X. Registration systems that reject ISBNs ending in X are themselves the bug: the letter is a legitimate part of the standard, not a typo.
The merger with EAN-13: the 2007 transition
- 1949–1952The concept’s patent
Norman Woodland and Bernard Silver file a patent for a pattern-based classifying system in 1949; it is granted on October 7, 1952, as US Patent No. 2,612,994. The two sold the rights for $15,000, the entire direct financial return they ever saw from the invention.
- 1967–1968ISBN is born, apart from retail
The book-numbering system begins in the United Kingdom in 1967 and reaches the United States in 1968 through R. R. Bowker. It starts as a 10-digit identifier, with its own check-digit math, unrelated to the barcodes that would come to dominate retail.
- April 3, 1973US retail picks the UPC symbol
US grocery-industry representatives adopt the rectangular Universal Product Code (UPC) design as the standard, ending years of competing proposals.
- June 26, 1974The first commercial scan
A ten-pack of Wrigley’s Juicy Fruit gum becomes the first product in the world scanned by a barcode reader, at a Marsh supermarket in Troy, Ohio. The product was picked on purpose: nobody was certain a code could even fit on a package that small.
- January 1, 2007ISBN becomes an EAN-13
Under the International ISBN Agency’s rule, every new ISBN becomes 13 digits, prefixed by 978 (or 979, added later), using the exact same modulo-10 algorithm as the retail barcode.
Converting an ISBN-10 to an ISBN-13 does not reuse the old check digit, it discards it and recomputes from scratch. Take the ISBN-10’s 9 data digits (without the check digit), prepend the 978 prefix, forming 12 digits, and apply the same modulo-10 math from EAN-13 in the previous section. The result is a new number, with a new check digit, representing the same book.
| Format | Full number | Data digits | Algorithm |
|---|---|---|---|
| ISBN-10 | 6547821935 | 654782193 (9 digits) | modulo 11, weights 10 to 2 |
| ISBN-13 | 9786547821933 | 978654782193 (12 digits) | modulo 10, weights 1 and 3 (same as EAN-13) |
Notice: it is the same book, the same 9 core digits (654782193), but two different check digits, 5 for ISBN-10 and 3 for ISBN-13, because they are two different calculations. The practical upside of the new format is that it prints as a genuine EAN-13: any store barcode reader, with no special logic for books, already knows how to read it. In Brazil, ISBN has been administered by the Câmara Brasileira do Livro (CBL) since 2020; before that, by the Fundação Biblioteca Nacional. The country prefix inside the ISBN changed too: 85 identified Brazil since the system’s adoption, but it ran out, and the International ISBN Agency released 65 as an additional Brazilian prefix starting in 2018. Older ISBNs starting with 85 remain valid, the new prefix only applies to new registrations. This platform’s ISBN lookup accepts both the 10- and 13-digit formats and fetches book metadata through BrasilAPI, but it does not recompute the check digit before querying, so it is worth doing the math yourself before reporting an ISBN as "broken".
What the check digit actually catches (and what it does not)
A check digit exists for a narrow purpose: catching a typo or a misread before it turns into a wrong order or a search with no results. The CPF and CNPJ validation guide shows this same principle applied to Brazilian documents, also a modulo-11 checksum, and the same caveat holds here: a "valid" code proves the arithmetic checks out, not that the product exists in a manufacturer’s catalog or that an ISBN maps to an actually published book. But the two checksum families in this guide do not catch the same errors with the same reliability, and the difference is mathematical, not a quirk of the standard.
EAN-13 / UPC-A (modulo 10)
- Catches 100% of single-digit substitutions.
- Catches most transpositions of neighboring digits.
- Does NOT catch a swap of two neighboring digits that differ by exactly 5 (0↔5, 1↔6, 2↔7, 3↔8, 4↔9).
ISBN-10 (modulo 11)
- Catches 100% of single-digit substitutions.
- Catches 100% of transpositions, neighboring or not, because 11 is prime and every weight is distinct.
- Cost: the check digit sometimes has to be the letter X.
| Scenario | What changes | Result |
|---|---|---|
| Typo | position 5: 4 becomes 9 → 789295108863 | checksum recomputes to 2, does not match the original 7: CAUGHT |
| Common transposition | positions 3 and 4 swap (9,2 → 2,9) → 782945108863 | checksum recomputes to 3, does not match the 7: CAUGHT |
| Transposition of digits 5 apart | 789275108863 (2,7) becomes 789725108863 (7,2) | both give checksum 4: NOT CAUGHT |
| The same swap, now on an ISBN-10 | 652278193 (2,7) becomes 652728193 (7,2) | gives X in one case and 5 in the other: CAUGHT |
The explanation is simple algebra. Swapping two neighboring digits changes the sum by the difference between the two weights (2, since the weights alternate between 1 and 3) times the difference between the two digits. When that digit difference is 5, the result is 2 × 5 = 10, and modulo 10 that simply vanishes: the final sum does not change. In ISBN-10, the difference between neighboring weights is always 1 (10, 9, 8...), so that same calculation never vanishes modulo 11, which is why it catches every transposition, not just most of them. The full step-by-step proof lives in an engineering write-up from the University of New Brunswick, cited in the sources, for anyone who wants the algebra line by line.
Frequently asked questions
How is the EAN-13 check digit calculated?
Why does an ISBN sometimes end in X?
Do the ISBN-10 and ISBN-13 of the same book share the same check digit?
Does a correct check digit guarantee the product or book is real?
Does the EAN-13 check digit catch any typing error?
Which barcode formats does this platform’s generator produce?
The last digit of an EAN-13, UPC-A or ISBN is never chosen, it is always computed. EAN-13 and UPC-A sum the digits before it with alternating weights of 1 and 3, weight 3 always on the digit closest to the check digit, and close in modulo 10. ISBN-10 sums with descending weights from 10 to 2 and closes in modulo 11, which sometimes becomes the letter X, a stricter check that catches every transposition, not just most. Since January 1, 2007, ISBN itself switched to the EAN-13 formula, prefixed by 978 or 979. Understand both formulas and you can, with pen and paper, tell a code with a typo from a genuine one, exactly what this platform’s barcode generator and ISBN lookup do in milliseconds.
Sources & references
- GS1, How to calculate a check digit manually
- International ISBN Agency, What is an ISBN?
- American Library Association, Fact Sheet 28: ISBN and ISSN Systems
- Tervo, R. (University of New Brunswick), Secrets of the ISBN: An Error Detection Method
- Google Patents, US2612994A, Classifying apparatus and method
- National Inventors Hall of Fame, Bernard Silver
- Marketplace, The inventors of the now-ubiquitous barcode received a patent 70 years ago
- GS1, Historical timeline
- Smithsonian Magazine, The History of the Bar Code
- GS1 Brasil, Types of barcodes
- Câmara Brasileira do Livro, ISBN numbering changes in Brazil