Utility Tools

EAN-13 Barcode Checksum Math: How the Modulo 10 Check Digit Is Calculated

Master barcode checksum math: Learn the step-by-step Modulo 10 algorithm used to compute the 13th check digit on EAN-13 and UPC-A retail barcodes.

October 06, 2026 6 min read Bhadresh Kotadiya
EAN-13 Barcode Checksum Math: How the Modulo 10 Check Digit Is Calculated
Summarize with:

Every EAN-13 retail barcode contains 13 numeric digits. The first 12 encode a country/region prefix, a manufacturer code, and a product code. The 13th and final digit is not part of the product identity at all β€” it's a mathematically derived check digit, computed from the other 12 using a Modulo 10 algorithm, whose entire purpose is letting a scanner detect a misread before it reaches the register.

Direct Answer: The EAN-13 check digit is calculated by multiplying the digits in odd positions (1st, 3rd, 5th, …, 11th, counting from the left) by 1, multiplying the digits in even positions (2nd, 4th, …, 12th) by 3, summing both results, and then computing:

Check Digit = (10 βˆ’ (Weighted Sum mod 10)) mod 10

Step-by-Step EAN-13 Calculation Example

Calculate the 13th check digit for the first 12 digits 4 003994 15548 (spacing is only for readability β€” the barcode encodes 12 contiguous digits):

Position 1 2 3 4 5 6 7 8 9 10 11 12
Digit 4 0 0 3 9 9 4 1 5 5 4 8
Weight Γ—1 Γ—3 Γ—1 Γ—3 Γ—1 Γ—3 Γ—1 Γ—3 Γ—1 Γ—3 Γ—1 Γ—3
  1. Sum the odd-position digits (weight Γ—1): positions 1,3,5,7,9,11 β†’ 4 + 0 + 9 + 4 + 5 + 4 = 26
  2. Sum the even-position digits and multiply by 3: positions 2,4,6,8,10,12 β†’ (0 + 3 + 9 + 1 + 5 + 8) Γ— 3 = 26 Γ— 3 = 78
  3. Add both totals: 26 + 78 = 104
  4. Take modulo 10, then subtract from 10: 104 mod 10 = 4 β†’ Check digit = 10 βˆ’ 4 = 6

Final valid EAN-13 barcode: 4003994155486

Worked UPC-A Example

UPC-A uses the same underlying arithmetic, but because a UPC-A code is really a 13-digit GS1 number with an implied leading zero stripped off, its 11 data digits carry the opposite weight pattern: odd positions Γ— 3, even positions Γ— 1.

Take the 11-digit UPC-A data 0 36000 29145:

Position 1 2 3 4 5 6 7 8 9 10 11
Digit 0 3 6 0 0 0 2 9 1 4 5
Weight Γ—3 Γ—1 Γ—3 Γ—1 Γ—3 Γ—1 Γ—3 Γ—1 Γ—3 Γ—1 Γ—3
  1. Odd positions Γ— 3: (0 + 6 + 0 + 2 + 1 + 5) Γ— 3 = 14 Γ— 3 = 42
  2. Even positions Γ— 1: 3 + 0 + 0 + 9 + 4 = 16
  3. Sum: 42 + 16 = 58
  4. Modulo 10, subtract from 10: 58 mod 10 = 8 β†’ Check digit = 10 βˆ’ 8 = 2

Final valid UPC-A barcode: 036000291452

Notice that if you prefix this UPC-A code with a leading 0 to form a 13-digit number (0036000291452) and run it through the EAN-13 formula instead, you get the identical check digit β€” confirming that UPC-A is mathematically a special case of EAN-13, not a separate numbering system.

Why the Weight Pattern Flips Between UPC-A and EAN-13

This is the detail that trips up most manual implementations. EAN-13's algorithm always assigns weight 1 to the 1st, 3rd, 5th… positions of its 12 input digits. UPC-A's algorithm assigns weight 3 to the 1st, 3rd, 5th… positions of its 11 input digits. These aren't two different conventions by coincidence β€” they're the same convention viewed from two different starting points. Prepending UPC-A's implicit leading 0 shifts every digit one position to the right, which flips odd positions into even positions and vice versa, and the weights flip along with them.

Why Check Digits Are Mandatory

Barcode scanners β€” whether laser-based or camera imagers (see our laser vs CCD scanner guide) β€” can occasionally misread a bar width due to print smudging, a worn label, or poor lighting. Without a check digit, a single misread bar could silently produce a different but still valid-looking 12-digit number, ringing up the wrong product or price with no indication anything went wrong.

With the check digit in place, the scanner recalculates the checksum from the first 12 digits it read and compares it to the 13th digit actually printed. If they don't match, the scanner rejects the read outright β€” typically with an error beep β€” rather than passing a corrupted number to the point-of-sale system. This single-digit safeguard is why barcode misreads at checkout are rare, despite the underlying optical scanning process being far from perfect.

Common Mistakes When Calculating Check Digits by Hand

  • Miscounting positions. The weighting alternates strictly by position within the 12 (or 11) input digits, starting from position 1 on the left β€” starting the count from the wrong end, or from position 0, flips every weight and produces a wrong (but plausible-looking) result.
  • Forgetting the final subtraction step. The weighted sum's modulo-10 remainder is not the check digit β€” it must still be subtracted from 10, and that result taken modulo 10 again to correctly handle the edge case below.
  • Mixing up UPC-A and EAN-13 weight patterns, as covered above β€” using EAN-13's weighting on UPC-A data (or vice versa) produces a check digit that's wrong roughly half the time.

What Happens When the Weighted Sum Is an Exact Multiple of 10?

If the weighted sum's remainder modulo 10 is already 0 β€” for example a weighted sum of 110 β€” the formula gives Check Digit = (10 βˆ’ 0) mod 10 = 10 mod 10 = 0, not 10. This final mod 10 step exists specifically to catch this edge case, since a check digit must always be a single digit (0–9).

Generate valid EAN-13 and UPC-A barcodes with automatically calculated check digits using our barcode generator, scan and verify retail barcodes with the barcode scanner, create 2D QR codes via the QR code generator, and scan QR codes with the QR code scanner. For background on how EAN-13 fits among other barcode standards, see our barcode symbologies comparison.

Frequently Asked Questions

What happens if the weighted sum is a multiple of 10, like 110?

The check digit is simply 0. Since 110 mod 10 = 0, the formula gives 10 βˆ’ 0 = 10, and 10 mod 10 = 0 β€” the final modulo step ensures the result is always a single digit rather than "10."

Is the EAN-13 check digit algorithm the same as the UPC-A algorithm?

They're mathematically equivalent but use opposite weight patterns on their own respective digit counts: EAN-13 applies weight 1 to odd positions and weight 3 to even positions across 12 digits; UPC-A applies weight 3 to odd positions and weight 1 to even positions across 11 digits. Both produce the same result as treating a UPC-A code as an EAN-13 code with a leading zero.

Can two different products ever have the same EAN-13 check digit?

Yes, easily β€” the check digit is a single digit (0–9) shared by roughly one in ten possible 12-digit prefixes. It's not meant to make barcodes unique; that's the job of the manufacturer and product code portions. Its only job is detecting a corrupted read of a specific barcode, not distinguishing between different barcodes.

Does the check digit protect against every possible scanning error?

No single-digit checksum catches every possible error, but the Modulo-10 algorithm used here is specifically effective at catching the most common real-world error types: single-digit misreads and adjacent-digit transpositions, which account for the large majority of practical barcode scanning mistakes.

Can I calculate a check digit for a 14-digit GTIN the same way?

Yes β€” the same alternating 3-and-1 weighting (defined by GS1 as starting from the digit immediately to the left of the check digit and alternating outward) extends to GTIN-14, GTIN-12 (UPC-A), and GTIN-8. Because the digit count differs, which absolute position gets weight 3 versus weight 1 shifts accordingly, which is exactly why UPC-A and EAN-13 have "opposite" looking weight patterns despite using the same rule.


References: GS1 Check Digit Calculator Specifications.

Free Calculator

Put this guide into action

Stop guessing β€” use our QR Code Generator to run real numbers, compare scenarios, and get instant results you can trust.

Use Free QR Code Generator
Bhadresh Kotadiya

Bhadresh Kotadiya Founder, EasyToolio (B.Tech in Computer Engineering)

Full-Stack Architecture, Web Performance & Technical SEO

Bhadresh Kotadiya is a full-stack software engineer with a B.Tech in Computer Engineering and the founder of EasyToolio. He builds the site and its calculators himself, working mainly with PHP, Laravel and Linux servers, and writes the technical guides on EasyToolio: developer tools, web performance, SEO, security and networking, and device and speed tests. He is the person to contact about how a tool works or if a calculation looks wrong.

Try Tool QR Code Generator
Use Tool

Continue Reading

AI ADVISOR & COACH

Ask AI Advisor

Ask AI