All guides

EAN-13 check digit: calculate and verify a GTIN-13

Calculate an EAN-13 check digit from twelve digits with the 1-3 weighting, verify a received GTIN-13 and handle leading zeros, wrong digits and blanks.

Product data8 min read
A practical guide to reviewing your catalogues.
View sources
In this guide 6 sections

To calculate an EAN-13 check digit, multiply the first twelve digits alternately by 1 and 3 from the left, add the products, then subtract the total from the next multiple of ten. For the synthetic string 123456789012, the weighted sum is 92, so the check digit is 8 and the complete GTIN-13 is 1234567890128.

To verify a GTIN-13 you have received, run the same calculation on its first twelve digits and compare the result with the thirteenth. A match shows that the digits are arithmetically consistent; it does not prove that the number is allocated, registered or attached to the right product.

GTIN-13 is the thirteen-digit identifier stored in a catalogue; EAN-13 is the barcode symbol that usually carries it on a label. The check digit is the same in both cases, because it belongs to the number, not to the barcode.

How to calculate the EAN-13 check digit

The GS1 method, described in the GS1 Germany check-digit sheet, weights the digits from right to left, always starting with 3 on the digit next to the check digit. For a twelve-digit string this gives weight 1 to the first digit on the left and weight 3 to the second.

  1. Write down the twelve digits without the check digit.
  2. Starting from the rightmost digit, assign the weights 3, 1, 3, 1… moving left.
  3. Multiply each digit by its weight.
  4. Add the products to get the weighted sum.
  5. Subtract the sum from the next multiple of ten (round up). The difference is the check digit. If the sum is already a multiple of ten, the check digit is 0.

Worked example on the synthetic string 123456789012:

Position (from left)123456789101112
Digit123456789012
Weight131313131313
Product163125187249016

The products add up to 92. The next multiple of ten is 100, so the check digit is 100 − 92 = 8. Written as a formula: check digit = (10 − (sum modulo 10)) modulo 10. This example is synthetic: it shows the arithmetic and is not a claim that 1234567890128 is allocated to any company.

How to verify a GTIN-13 you have received

You can verify a received number in two equivalent ways:

  • Recalculate: take the first twelve digits, calculate the check digit as above and compare it with the thirteenth digit.
  • Weight all thirteen digits: weight the full number from the right with 1, 3, 1, 3… (the check digit gets weight 1). The total must be a multiple of ten. For 1234567890128, the total is 92 + 8 = 100, so the number is consistent. For 1234567890127, the total is 99: one digit is wrong.

When the check fails, report the original thirteen digits to the manufacturer rather than replacing the last digit with the calculated one. The arithmetic only tells you that a digit is wrong somewhere; the mistyped digit may be in the middle of the number. A GTIN that differs from the previous edition needs a different review, set out in the product identity check for a changed GTIN. If the GTIN is also used as a matching key between two editions, keep it as text with the rules in normalising product codes without losing leading zeros.

What a correct check digit does and does not prove

GS1 US presents the check digit as a way to confirm that an identifier has been entered correctly, as its check digit calculator page explains. That is its whole purpose.

What the check catches:

  • Any single wrong digit. Changing one digit always changes the weighted sum by an amount that is not a multiple of ten. In the synthetic example, typing 8 instead of 5 in position 5 gives 1234867890128, whose thirteen-digit total is 103.
  • Most swaps of two neighbouring digits, because the two digits change weights.

What it misses:

  • A swap of neighbouring digits that differ by 5, such as 16 and 61. The synthetic strings 161234567890 and 611234567890 both give check digit 6.
  • Two errors that cancel each other out.
  • Identity questions. A consistent number can still be allocated to another product, belong to a unit rather than a case, or have been copied from the wrong row. The checksum says nothing about brand ownership or registration.

Leading zeros, GTIN-12 and 14-digit fields

Leading zeros never change the check digit. Because the weighting starts from the right, a zero added on the left is multiplied by a weight and adds nothing to the sum. The synthetic GTIN-12 012345678905 keeps the check digit 5 when it is written on thirteen digits (0012345678905) or fourteen digits (00012345678905).

This is why some systems store every GTIN on fourteen digits. GS1 Australia, for example, requires that a GTIN in its national product catalogue is always entered with 14 digits, padded with leading zeros, as stated in its GTIN data attribute definition. The same page lists GTIN-14, GTIN-13, GTIN-12 and GTIN-8 as valid formats.

The practical risks are in the spreadsheet, not in the arithmetic:

  • A column read as a number drops the leading zeros, so 0012345678905 becomes 12345678905. Set the column type before opening the file, as shown in importing CSV into Excel with UTF-8, delimiters and quotes.
  • A long number shown in scientific notation, or rounded, has lost digits for good. Adding a fresh check digit does not repair it: go back to the sender’s file.
  • A twelve-digit value in a GTIN-13 column may be a GTIN-12 that needs padding, or a GTIN-13 with a missing digit. Confirm which format the field expects before calculating.

Check a GTIN column in a supplier catalogue

Before the checksum, establish that the column really holds GTINs and not an internal product code or another GS1 key. Keep the original string and the source row for every value. Then give each row one of five outcomes, so that each one leads to a clear action:

Synthetic inputOutcomeAction
1234567890128Consistent check digitKeep the value as received.
0123456789050Consistent, check digit 0 (the first twelve digits sum to 110)Keep all thirteen digits, including the leading zero.
1234567890127Wrong check digit (received 7, calculated 8)Report the original digits to the manufacturer; do not substitute 8.
123456789012Unexpected length for a GTIN-13 fieldConfirm the format (GTIN-12 or truncated GTIN-13) with the sender.
12345 67890128 or emptyNon-numeric characters or blank cellRecord the value as it is; do not strip characters silently.

When the same catalogue arrives in a new edition, compare the GTIN column with the previous one, not only with the checksum: a number that passes the check but changed between editions is the case the checksum cannot detect. The sample difference report on the features page shows how changed fields are listed by product code, and the supplier catalogue comparison explains how two editions from the same manufacturer are compared.

Frequently asked questions

Is the EAN-13 check digit the same as the GTIN-13 check digit?

Yes. GTIN-13 is the number and EAN-13 is the barcode that carries it, so the thirteenth digit is the same check digit in both cases.

How do you calculate a GTIN check digit by hand?

Weight the digits from right to left with 3, 1, 3, 1 and so on, add the products and subtract the sum from the next multiple of ten. The same method applies to GTIN-8, GTIN-12, GTIN-13 and GTIN-14.

Does a leading zero change the check digit?

No. The weighting starts from the right, so zeros added on the left add nothing to the weighted sum and the check digit stays the same.

Does a valid check digit mean the barcode is registered?

No. A correct check digit only shows that the digits are consistent with each other. It does not show that the number is allocated, registered or assigned to the product described in the catalogue.

What should you do when a check digit is wrong?

Keep the original value, flag the row and ask the manufacturer for the correct number. Do not replace the last digit with the calculated one, because the error may be in another position.

Official sources & scope

This guide describes a working method. The examples are fictional; the official documentation remains the reference for the format rules. CatalogInspect is an independent service.

Back to guides & resources

Request access to CatalogInspect.

Enter your work email address to request access to CatalogInspect.

Submitting sends your request to BankStatementLab’s infrastructure for CatalogInspect. It does not create an account, trigger a payment or send an automatic email. Privacy.