Type one wrong digit from a 13-digit GS1 product number and its check will fail. Swap two neighboring digits, though, and the number can still pass. The last digit is calculated from the 12 digits before it.
Take the hypothetical product number 0001234567161. Change the 6 just before the final 1 to a 7 and the check fails. Swap the neighboring data digits 1 and 6 instead, and 0001234567611 still passes. The difference comes from how the calculation weights each position.

Calculate the last digit
The 13-digit Global Trade Item Number, or GTIN-13, uses alternating weights of 1 and 3. Start at the left of the 12 data digits with weight 1. The twelfth digit has weight 3. Leave the check digit out of this calculation.
For 000123456716, group the digits by weight.
- Weight 1 gives \(0+0+2+4+6+1=13\).
- Weight 3 gives \(3(0+1+3+5+7+6)=66\).
The weighted total is \(13+66=79\). Add 1 to reach 80, so the check digit is 1. If the weighted total already ends in zero, the check digit is 0.
Why changing one digit fails the check
Changing the twelfth digit from 6 to 7 adds 3 to the weighted total. That brings it to 82. The new string would need a check digit of 8 to reach 90, so keeping the original 1 fails the check.
Any change to one data digit adds or subtracts a number from 1 through 9, multiplied by the position’s weight. With weights of 1 and 3, none of those changes is a multiple of 10. The required check digit therefore changes. If the typo is in the check digit itself, the calculated digit still gives the correct value to compare against.
Why swapping two neighbors can pass
In the original string, the last two data digits contribute \(1+3(6)=19\). After the swap, they contribute \(6+3(1)=9\). The weighted total drops from 79 to 69. Both totals end in 9, so both need the same check digit of 1.
For adjacent data digits \(a\) and \(b\) in positions weighted 1 and 3, swapping them changes \(a+3b\) to \(b+3a\). The difference is \(2(a-b)\). If the positions carry weights 3 and 1 instead, the change has the opposite sign. Either way, swapping two distinct neighboring data digits leaves the check digit unchanged exactly when those digits differ by 5. Then the weighted total changes by 10 in one direction or the other.
If a number fails the check, start by rereading the digits on the label. For a number that passes, compare the full identifier with the label or a trusted product record when you need to confirm which item it belongs to.


