# Validation of UPC and EAN Barcode Numbers

All UPCs are 12-digit numbers, but not every 12-digit number is a valid UPC.

How so? Because every UPC has what's called a "check digit". This check digit — the last digit in every UPC — helps to catch errors like typos and provide some degree of confidence that you're actually dealing with a UPC.

EAN codes are similar. Though they have 13 digits, they too have a final check digit to help weed out errors.

## Just because it validates...

...doesn't mean that it is an active UPC!

That's right; a lot of 12-digit (and 13-digit) numbers will “validate” as a UPC (or EAN), but that doesn't mean the code has actually been assigned to a product. That said, if it validates the number could be assigned in the future, so it may wind up on a product someday.

If you're wondering what product a particular number is associated with — if any — you can always plug it into our search form to check against our database of millions of UPCs.

## How UPC Validation Works — An Example

Let's break down the logic for validating a UPC. For an example, we'll use the code `829576019311`. One (`1`) is the check digit in this case.

With the following 5 steps we will confirm this UPC is valid:

1. Take all of the odd-position digits — the 1st, 3rd, 5th, 7th, 9th, and 11th digits — and add them together.
`8 + 9 + 7 + 0 + 9 + 1 = 34`
2. Multiply the result of step 1 (`34`) by the number `3`.
`34 * 3 = 102`
3. Now, take all of the even-position digits (positions 2, 4, 6, 8 and 10), and add them together.
`2 + 5 + 6 + 1 + 3 = 17`
4. Take the sum of the results from steps 2 and 3.
`102 + 17 = 119`
5. The check digit is calculated by figuring out what number needs to be added to the result of step 4 in order to make it a multiple of 10.
`119 + 1 = 120`

Therefore, the check digit for this UPC barcode is `1`.

## Example EAN Validation

Validating an EAN is very similar; we're just dealing with one additional digit. For this example, we'll use the code `5900049003619`.

Here are the 5 steps to validate this EAN code:

1. Take all of the odd-position digits (exluding position 13, since this last number is the check digit), and add them together.
`5 + 0 + 0 + 9 + 0 + 6 = 20`
2. Now, take all of the even-position digits (positions 2, 4, 6, 8, 10, and 12), and add them together.
`9 + 0 + 4 + 0 + 3 + 1 = 17`
3. Multiply the result of step 2 (`17`) by the number `3`.
`17 * 3 = 51`
4. Take the sum of the results from steps 1 and 3.
`20 + 51 = 71`
5. The check digit is calculated by figuring out what number needs to be added to the result of step 4 in order to make it a multiple of 10.
`71 + 9 = 80`

Therefore, the check digit for this EAN barcode is `9`, and we confirm that `5900049003619` is a valid EAN.