Menu

DON'T GO SHOPPING
without the UPCZilla app!
The stores hate it ;)

Get it on Google Play

Google Play and the Google Play logo are trademarks of Google LLC

UPC validity

If a UPC is invalid it usually means that the user has entered it incorrectly somewhere down the line. So ANY handling of UPCs (and other types of product/bar code) should involve validity checking. We check the validity of every UPC on our site (you can too with our new UPC validation tool!) and either display the product, or else some kind of error message. Here are a couple of the errors our site finds with UPCs:

  1. A UPC must have 12 digits. So if a UPC doesn’t have 12 digits then it is wrong to begin with. Very often the problem is a 0 missing from the beginning because retailers think the leading 0 doesn’t matter (it does), or maybe Excel or some other software strips it out for them. These will pop up sometimes when you search for a product on a particular keyword – then you will see an error like “invalid UPC – not 12 digits“. Sometimes our site will offer to add or remove a leading zero to see if that results in a valid UPC.
  2. A UPC must have a valid checksum. The barcode can be of the correct length – 12 digits – but the checksum can still not check out. If you are unfamiliar with the concept of a checksum, basically it usually involves a single digit (the rightmost, in the case of UPCs and most other barcodes) which is derived from an algorithm performed on the remaining 11 digits. If any of the digits are wrong then the checksum won’t be correct. Or to put it another way, if the checksum is wrong then we know a digit in the UPC itself is wrong. It’s far from being a perfect method – collisions (false positives) are possible, but usually if just one digit has been wrongly typed in or something then the algorithm will catch it. If you are interested, this is the formula that is used to calculate the checksum for UPCs:
  1. Take the digits in the odd-numbered positions (1st, 3rd, 5th etc.), add them together and multiply the result by three.
  2. Take the digits in the even-numbered positions (2nd, 4th, 6th – but NOT the 12th digit to the right if it is there, since this will be the existing checksum) and add these to the result.
  3. Divide this result by 10 and take the remainder (modulo 10), and if it is not 0, subtract it from 10 to derive the check digit, otherwise use 0.

We now have an online UPC validation tool which demonstrates this validation process, check it out!