Standards October 25, 2026 6 min read By BarcodeForge Team

Barcode Check Digits Explained (With the EAN/UPC Formula)

What the last digit of a barcode really does, how the modulo-10 algorithm works step by step, and how Code 128's mod-103 check differs. With worked examples.

The last digit of every retail barcode is not part of the product number — it is a mathematical bodyguard. The check digit catches mistyped numbers and misread bars before bad data enters a system. This article explains exactly how it works, with a worked example you can verify by hand.

Why check digits exist

Humans transpose digits (typing 49 instead of 94) and scanners occasionally misread a bar. Without protection, a single wrong digit could ring up the wrong product or ship a parcel to the wrong depot. A check digit is computed from all the other digits, so any change to the data almost always breaks the relationship and the number is rejected instantly.

The GS1 modulo-10 algorithm, step by step

EAN-13, UPC-A, EAN-8, ITF-14 and SSCC all use the same algorithm. The key detail most tutorials get wrong: weights are assigned from the right, not the left.

  1. 1 Take the data digits (all digits except the check digit).
  2. 2 Starting from the rightmost data digit, multiply alternating digits by 3 and 1 (rightmost × 3, next × 1, next × 3, …).
  3. 3 Sum all the products.
  4. 4 The check digit is the amount needed to reach the next multiple of 10: (10 − (sum mod 10)) mod 10.

Worked example: EAN-13

Data digits: 590123412345 (12 digits, check digit unknown). From the right, weights alternate 3,1,3,1…:

digits:  5 9 0 1 2 3 4 1 2 3 4 5
weights: 1 3 1 3 1 3 1 3 1 3 1 3
products:5+27+0+3+2+9+4+3+2+9+4+15 = 83
check = (10 - (83 mod 10)) mod 10 = (10 - 3) mod 10 = 7
full GTIN: 5901234123457

Why weighting from the right matters

For 12 data digits (EAN-13) the pattern happens to align with left-based shortcuts, which is why some tutorials appear to work. But for UPC-A (11 data digits) or ITF-14 (13 data digits), a left-based pattern produces wrong results. Right-based weighting is the one rule that works for every GTIN length.

What errors does mod-10 catch?

  • All single-digit errors (one wrong digit).
  • Most adjacent transpositions (swapped neighbouring digits).
  • It misses some twin errors (aa → bb where the difference is 5) and certain jump transpositions — no single decimal check digit catches everything.

Code 128 uses a different check: modulo 103

Code 128's check character is a weighted sum of symbol values: the start character value plus each data character value multiplied by its position, all modulo 103. It is encoded as an extra symbol character before the stop pattern and is never shown in the human-readable text. Because it covers character values rather than decimal digits, it is stronger than mod-10 for alphanumeric data.

Code 39 by contrast is 'self-checking' — its character structure makes most single errors detectable without a check character — though an optional mod-43 check exists for high-security applications.

Check digits in 2D codes

QR codes and Data Matrix do not use a trailing check digit. Instead they embed Reed–Solomon error correction across the whole symbol, which not only detects but repairs damage. That is a fundamentally stronger approach — covered in our QR error correction guide.

Practical rules

  1. 1 Never invent the last digit of a GTIN — compute it or let a generator do it.
  2. 2 When converting ISBN-10 to ISBN-13, recalculate the check digit after adding 978.
  3. 3 If a marketplace rejects your GTIN as invalid, run the mod-10 check first — a wrong check digit is the most common cause.
  4. 4 Use generators that compute checks automatically (BarcodeForge does for every symbology that requires one).

One digit, one multiply-and-sum, and decades of data-entry errors prevented. The check digit is the quiet workhorse of the entire GS1 system.

Tags: check digitmodulo 10ean-13upcvalidation

Try it yourself — free, no signup

Generate any barcode or QR code mentioned in this guide, with correct check digits and print-ready export.

Related guides