EAN, UPC and ISBN check digit: how it is calculated
The last digit of a barcode or an ISBN is not random: it is calculated from the others so that a reader can catch a typing or scanning error. The sum fits on one line and takes a minute by hand. How it works for EAN-13, EAN-8, UPC-A and ISBN, with worked examples, and which errors it catches and which it does not.
What the check digit is for
It is a verification digit: calculated with a formula from all the others, and whoever reads the code repeats the sum. If the result does not match, there is an error. So a scanner that misreads a bar or a person who mistypes a digit notices straight away, without consulting any database. There is one important limit: a correct check digit only means the number is well formed. It does not say whether it exists, or who it belongs to.
EAN-13 and GS1 codes: the sum
The GS1 General Specifications, from the organisation that manages these codes, define it like this: multiply the digits (not counting the check digit) alternately by weights 3 and 1, starting with 3 on the rightmost digit; add up the results; and the check digit is whatever is needed to reach the next multiple of ten.
A worked example with the ISBN that the ISBN manual itself uses as a model, 978-92-95055-12-?. Its first 12 digits, with the weight each gets (1 for the first, 3 for the second, and so on alternately):
| Digit | 9 | 7 | 8 | 9 | 2 | 9 | 5 | 0 | 5 | 5 | 1 | 2 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Weight | 1 | 3 | 1 | 3 | 1 | 3 | 1 | 3 | 1 | 3 | 1 | 3 |
| Product | 9 | 21 | 8 | 27 | 2 | 27 | 5 | 0 | 5 | 15 | 1 | 6 |
The sum is 9 + 21 + 8 + 27 + 2 + 27 + 5 + 0 + 5 + 15 + 1 + 6 = 126. The next multiple of ten is 130, and 130 − 126 = 4. Check digit: 4, and the full code is 9789295055124 (as an ISBN, 978-92-95055-12-4). Put another way: the remainder of 126 divided by 10 is 6, and 10 − 6 = 4; if the remainder were 0, the digit would be 0.
To check a complete code there is a shorter route: weight all 13 digits with 1, 3, 1, 3… and the sum must be a multiple of 10. In the example, 126 + 4 = 130.
EAN-8 and UPC-A: the same with another length
The algorithm is identical for all fixed-length numeric GS1 identifiers; only the number of digits changes. The rule “the 3 goes on the digit nearest the check digit” works for any length.
- EAN-8 (7 digits + check). For 9638507: 9×3 + 6×1 + 3×3 + 8×1 + 5×3 + 0×1 + 7×3 = 27 + 6 + 9 + 8 + 15 + 0 + 21 = 86 → next ten 90 → check 4. Code: 96385074.
- UPC-A (11 digits + check, the code of the United States and Canada). For 03600029145: the weighted sum is 58 → check 2. Code: 036000291452.
ISBN-10: a different system, with an X
Until 2006 books were identified with 10-digit ISBNs, and they are still everywhere on older books. Their digit is calculated with a different method: multiply the first 9 digits by weights 10, 9, 8… 2, add them up, and the check digit is whatever is needed to reach the next multiple of 11. If that comes to 10, it is written as X.
Example with 0-306-40615-?: 0×10 + 3×9 + 0×8 + 6×7 + 4×6 + 0×5 + 6×4 + 1×3 + 5×2 = 0 + 27 + 0 + 42 + 24 + 0 + 24 + 3 + 10 = 130. 130 divided by 11 leaves remainder 9, and 11 − 9 = 2. The full ISBN is 0-306-40615-2. To check a complete one, weight all 10 digits with 10, 9, 8… 1 and the sum must be a multiple of 11 (here, 132 = 11 × 12).
Since 1 January 2007, national agencies only assign 13-digit ISBNs. An ISBN-13 is exactly an EAN-13 starting with 978 or 979, the prefixes GS1 reserves for the International ISBN Agency (part of 979 is sub-allocated to music, as ISMN), which is why a book's barcode is an ordinary EAN-13. To convert an ISBN-10 to an ISBN-13, put 978 in front, drop the old check digit and calculate the new one with the EAN-13 sum: 0-306-40615-2 becomes 978-0-306-40615-7.
Which errors it catches and which slip past
With EAN's weights of 3 and 1, the check digit always catches a single-digit error (any one digit changed to another), the commonest typo. It also catches almost all swaps of two adjacent digits, but not all: it misses swapping two digits that differ by 5 (for example 2 and 7, or 0 and 5), because the change in the sum turns out to be a multiple of 10. It is a known limitation of the method, so a code with a correct digit is no absolute guarantee that it was typed right.
Two useful clarifications
- The prefix is not the country of manufacture. The first digits of a GS1 code identify the organisation that allocates numbers to companies, not where the product is made. Some prefixes also have a special use: 978 and 979 are for books, 977 for serial publications (ISSN), and 20 to 29 are reserved for restricted-circulation numbers within a region, not for general sale.
- Calculating the digit does not give you the right to use the number. Product codes for selling in shops are licensed by each country's GS1 organisation. A generator can draw any number, but that number may match a product that already exists.
Checking without the sums
The ISBN and EAN validator tells you whether a code's check digit is right, converts between ISBN-10 and ISBN-13 and completes a code that is missing its last digit. And to draw the barcode of a number (EAN-13, EAN-8, UPC-A, Code 128…) as PNG or SVG, use the barcode generator, which adds the check digit if you leave it out. Both run in your browser.
Sources and further reading
- GS1: General Specifications (release 26, January 2026), section 7.9.1 (check digit algorithm) and section 1.2.3 (GS1 prefixes)
- International ISBN Agency: ISBN Users' Manual, 7th edition (structure, EAN-13 bar code and appendix 1, check digit calculation)
Figures checked on 3 October 2026.
Do it now, free, in your browser. Your files are not uploaded.
Check ISBN, EAN and UPC codes, and convert ISBN-10 to ISBN-13.
Frequently asked questions
How is the check digit of an EAN-13 calculated?
How do I know whether an EAN-13 code is valid?
How is the check digit of an ISBN-10 calculated?
How do I convert an ISBN-10 to an ISBN-13?
Which errors does the check digit catch?
Does a barcode prefix show the country of manufacture?
Related guides
Tools used in this guide
They run in your browser, so nothing is uploaded.