UPCZilla’s tool for validating UPCs which also gives you a handy explanation of how the validation was performed.
Online UPC validation tool
031398210771 is a valid UPC-A (though that doesn't mean it's assigned to any products, click here to see if it is: 031398210771 - if you haven't already).
How do we check if a UPC is valid?
To check if a UPC is valid, we need to perform some calculations on its digits, as follows:
- We take the six odd numbered digits (counting from the left, not including the final digit - more about that at the end) and we add them together:
0 3 1 3 9 8 2 1 0 7 7 (1) - last digit ignored for now
0 (digit 1) + 1 (digit 3) + 9 (digit 5) + 2 (digit 7) + 0 (digit 9) + 7 (digit 11) = 19
- Then we multiply that number (19) by 3:
19 X 3 = 57 (we'll be using this number in a minute)
- Then, similar to the first step, we take the FIVE (not six) EVEN numbered digits and we add them together as well:
0 3 1 3 9 8 2 1 0 7 7 (1) - last digit still ignored
3 (digit 2) + 3 (digit 4) + 8 (digit 6) + 1 (digit 8) + 7 (digit 10) = 22
- We get the number we got in step 3 (22) and we ADD it to the number we got in step 2 (57):
22 + 57 = 79
- Now we take the number we got in step 4 (79) and work out how much we have to add to round it up to the nearest 10. In order to round 79 up to the nearest 10 (80) we have to add... 1
- Is this value of 1 the same as the last (rightmost) digit in our code - the one we ignored in steps 1 and 3 (that's our checksum)?
YES, the checksum in our UPC was also 1 so the UPC is valid!
The rightmost digit in a UPC is a checksum, because it provides some insurance that all the other numbers are right by performing the above calculation on them. The system is not foolproof, but if any number is wrong then you will typically get a wrong checksum.