How Barcode Check Digits Work (With a Worked Example)

Published 9 October 2026

The last digit of an EAN or UPC barcode isn't random. It's a check digit, and it's there to catch mistakes. Here's how it's calculated, with a real example you can follow.

Digit590123412345
Weight (from the right)131313131313
Result52703294329415

The results add up to 83. The next multiple of 10 is 90, so the check digit is 7.

What a check digit is for

A scanner can occasionally misread a bar, and people sometimes mistype a number. A check digit is a single extra digit, calculated from all the other digits. When a number comes in, the system does the same calculation and compares. If the result doesn't match, the number is rejected instead of pointing at the wrong product.

It doesn't make a barcode secret or secure. It just catches honest mistakes, such as a single wrong digit, and most cases where two neighbouring digits are swapped.

Calculating an EAN-13 check digit

Let's work out the check digit for the 12 digits 590123412345.

  1. Write the digits down: 5 9 0 1 2 3 4 1 2 3 4 5.
  2. Starting from the right, multiply them alternately by 3 and 1. The right-most digit gets 3, the next gets 1, the next gets 3, and so on.

That gives: 5×3 = 15, 4×1 = 4, 3×3 = 9, 2×1 = 2, 1×3 = 3, 4×1 = 4, 3×3 = 9, 2×1 = 2, 1×3 = 3, 0×1 = 0, 9×3 = 27, 5×1 = 5.

  1. Add them up: 15 + 4 + 9 + 2 + 3 + 4 + 9 + 2 + 3 + 0 + 27 + 5 = 83.
  2. Find how much you need to reach the next multiple of 10. The next multiple of 10 after 83 is 90, so the check digit is 7.

The complete EAN-13 number is 5901234123457. You can check it by entering the 12 digits into the EAN-13 generator. It adds the 7 for you.

What if you type a wrong check digit?

Enter 5901234123458 instead, and the generator will tell you the last digit should be 7, rather than quietly making a barcode that won't validate. That's deliberate: a barcode with a wrong check digit would be rejected by many tills.

Other formats do the same thing

  • UPC-A and EAN-8 use the same alternating 3 and 1 idea, with different lengths.
  • ITF-14 uses the same method on 13 digits to make the 14th.
  • Code 128 has its own built-in check character, which is added automatically and isn't shown to you.
  • Code 39 doesn't need one, because every character is self-contained.

Why you don't need to do this by hand

You'll rarely need to calculate it yourself, because the generators on this site do it automatically, and check it if you type the full number. But knowing how it works helps when a barcode is rejected. Nine times out of ten, the check digit is the reason.

Try it yourself

Pick any 12-digit number. Enter it into the EAN-13 generator and see the digit it adds. Then do the sum by hand and check you get the same answer. It's a satisfying five minutes, and it shows you the method is the same on every product barcode.

What it can and can't catch

A check digit catches most single-digit mistakes and many cases where two neighbouring digits are swapped. It can't catch every possible error, and it doesn't prove that a number is real or belongs to you. A number can pass the check and still not be registered to any product. For that reason, retailers also check numbers against GS1 records.

Why barcodes get rejected

If a till, marketplace or warehouse system rejects your number, check three things in order: the digits you typed, the check digit, and whether you've used the right barcode type. The generators here tell you the correct check digit if you enter a wrong one, which makes the first two checks quick. For help with the last, see EAN-13 vs UPC-A.

Frequently asked questions

What is a check digit?

It's the last digit of a number such as an EAN or UPC. It's calculated from the other digits and used to catch typing and scanning mistakes.

Can I choose my own check digit?

No. It's calculated from the other digits, and a wrong one makes the barcode invalid.

Why did the generator reject my 13-digit number?

The last digit didn't match the one calculated from the first 12. The message tells you what it should be.

Does Code 128 have a check digit?

Yes, a built-in check character that's added automatically. You never type it.

More guides

See all guides