CodeBox Hub
FREE

EAN-13 Check Digit: How to Calculate It, Validate It, and Where It Fails

The EAN-13 (GTIN-13) check digit: the 3/1 weighted formula, a worked example, how to validate a code you already have, and what the digit cannot catch.

# EAN-13 Check Digit: How to Calculate It, Validate It, and Where It Fails

The EAN-13 check digit is the thirteenth digit of a GTIN-13. Take the first twelve digits, multiply the odd-position digits by 1 and the even-position digits by 3, add the results, and the check digit is (10 − sum mod 10) mod 10. For 400638133396 the weighted sum is 98, 98 mod 10 is 8, so the check digit is 2 and the complete code is 4006381333962. It catches every single mistyped digit, but as our own enumeration below shows, it misses entire classes of keying errors. Our free EAN-13 generator computes this digit automatically.

Calculating the EAN-13 Check Digit Step by Step

GS1 defines the rule in its General Specifications; the symbology itself is standardised as ISO/IEC 15420. Worked example for the twelve data digits 400638133396:

StepOperationResult
1Digits in odd positions (1, 3, 5, 7, 9, 11) × 14 + 0 + 3 + 1 + 3 + 9 = 20
2Digits in even positions (2, 4, 6, 8, 10, 12) × 3(0 + 6 + 8 + 3 + 3 + 6) × 3 = 26 × 3 = 78
3Add both groups20 + 78 = 98
4Take the sum modulo 1098 mod 10 = 8
5Subtract from 10, then modulo 10 again(10 − 8) mod 10 = 2

The finished code is 4006381333962. The second modulo step matters: when the sum already ends in 0 the check digit is 0, not 10. Position numbering starts at the leftmost digit, which is what makes the "odd × 1, even × 3" phrasing correct for a 12-digit data body only — see the cross-format section below for the version that works for every length.

If you would rather not do arithmetic by hand, enter the twelve digits in the generator and it appends the correct digit, then exports the symbol with guard bars and quiet zones to PNG, SVG or PDF for your label printer. The tool's built-in example is 590123412345, which resolves to 5901234123457.

What the Check Digit Catches — and What It Never Catches

Marketing copy usually claims the check digit "detects most errors". We tested that claim instead of repeating it: we enumerated every single-digit substitution and every two-position transposition, recomputing a valid check digit for each constructed code and asking whether the corrupted code still passes validation.

Error you actually makeCases testedDetectedUndetected
One digit keyed wrong (any of 13 positions)117117 (100%)0
Two neighbouring digits swapped990880 (88.89%)110
Two digits swapped with one digit between them2,7000 (0%)2,700
Any two positions swapped (66 position pairs)5,9402,880 (48.48%)3,060

The pattern follows directly from the weights. A single wrong digit changes the weighted sum by weight × difference; because the weights 1 and 3 are both coprime with 10, that can never be a multiple of 10 — so 100% of single-digit errors are caught. A swap is invisible exactly when (difference) × (weight_i − weight_j) is a multiple of 10. Neighbouring positions have weights 1 and 3, so the difference of weights is 2 and only digit pairs that differ by 5 slip through — which is why the 110 misses all have a |difference| of 5. Positions two, four or six apart carry the same weight, so their swaps change nothing at all.

Concrete example from the enumeration: 4006381333962 and 4006331833962 differ only by a swap at positions 6 and 8, and both pass check-digit validation. A scanner will happily accept either. Practical consequence: never retype a product number from memory or from a screenshot without reading the digits back in order — the checksum is not a safety net for that class of mistake.

Validating an EAN-13 You Already Have

To check a printed or supplied 13-digit code:

  1. Confirm it is exactly 13 characters, all digits, and that the human-readable number matches the bars if you can re-scan it.
  2. Recompute the check digit over the first twelve digits with the formula above and compare it with the thirteenth.
  3. Look up the leading digits in the GS1 prefix allocation to see which GS1 member organisation issued the company prefix.
  4. For authenticity — as opposed to arithmetic validity — query GS1's GEPIR database, which returns the brand owner that registered the GTIN. A correct check digit proves only that the number is well formed, never that the product is genuine or that the code is registered.

On this site the barcode generator hub validates input shape: EAN-13 expects 12 digits, EAN-8 expects 7, UPC-A expects 11 and ITF-14 expects 13, and anything that does not fit the format is refused rather than silently encoded. Encoding runs entirely in your browser, so a product number you type is never uploaded — useful when you are checking codes from a supplier list before printing barcode labels.

The Same Rule for EAN-8, UPC-A, ITF-14 and GTIN-14

The formulation "odd positions × 1, even positions × 3" breaks for other lengths, because the number of data digits changes. The portable GS1 rule is: start at the digit immediately left of the check digit and apply weights 3, 1, 3, 1… moving left. We computed the check digit for one example of each length:

FormatTotal digitsData digitsWeight of leftmost digitWorked example
EAN-8 (GTIN-8)8739638507 → check 4 → 96385074
UPC-A (GTIN-12)1211303600029145 → check 2 → 036000291452
EAN-13 (GTIN-13)13121400638133396 → check 2 → 4006381333962
ITF-14 (GTIN-14)141331061414100001 → check 9 → 10614141000019

That single table also answers the most common structural question: EAN-13 and UPC-A share one algorithm, and a UPC-A becomes a GTIN-13 by adding a leading zero, so EAN-13 vs UPC-A is a presentation difference, not a mathematical one. For logistics cartons the same mod-10 family continues at ITF-14, and compact packs use EAN-8.

"EAN-128" Is Not a Longer EAN-13

In our own Search Console data, queries mixing "EAN" and "128" (ean 128, ean-128, ean 13) brought our pages hundreds of impressions in the last 28 days at positions 20–80, so the confusion is measurable. EAN-128 is the retired name of GS1-128, a Code 128 based carrier for Application Identifiers such as batch, expiry and serial numbers. It has no thirteenth digit at all: its check character is part of the Code 128 symbol checksum, computed with weights increasing 1, 2, 3… from the right, and it is a symbol character rather than a printed digit. If your data needs more than a product number, use the Code 128 generator and read the Code 128 structure guide; the decision table in EAN-13 vs Code 128 covers which retail and logistics systems accept which.

Five Mistakes That Survive Validation

  • Retyping a number and swapping two digits of the same weight class, as in the example above: 0% detected.
  • Assuming a valid checksum means a registered or genuine product; it does not, and marketplaces increasingly check GS1 registration records instead.
  • Reading the leading digits as country of origin. They record where the company prefix was issued, not where the item was made — see the EAN-13 structure guide.
  • Mixing formats inside one numbering system, for example a UPC-A printed on a pack and a zero-prefixed EAN-13 in the catalogue; the numbers differ on screen and are identical in the database.
  • Choosing a retail GTIN for internal SKU work, where a non-registered code and a Code 39 or Code 128 symbology avoid paying for GS1 numberspace. All formats and their check-digit rules are compared in the symbology overview.

FAQ

How do I calculate an EAN-13 check digit?

Multiply the first twelve digits alternately by 1 and 3, starting with 1 on the leftmost digit, and add the products. Subtract the last digit of that sum from 10; if the result is 10, the check digit is 0.

What is the check digit for 400638133396?

It is 2. The weighted sum is 98, 98 mod 10 is 8, and 10 − 8 is 2, giving the complete EAN-13 4006381333962.

Can I look up who owns an EAN-13 number?

Query GS1's GEPIR database with the full 13 digits; it returns the brand owner that registered the GTIN. Registration databases cover only numbers registered with GS1, so a hit proves registration, and no hit does not automatically prove a code is fake.

Does the EAN-13 check digit detect swapped digits?

Only sometimes. In our enumeration of 990 neighbouring-digit swaps, 880 were detected, and every miss involved digits differing by exactly 5. Swaps between positions two or four apart were detected 0 times, because those positions share the same weight.

Is GTIN-13 the same thing as EAN-13?

Yes. GS1 renamed EAN-13 to GTIN-13 when it unified its numbering standards; the barcode symbology carrying it is still EAN-13 in ISO/IEC 15420, and the printed 13 digits are interchangeable in retail systems.

How many digits are in an EAN-13 and which one is the check digit?

Thirteen digits, and the thirteenth is the check digit. The preceding twelve carry the GS1 company prefix and the item reference, and the human-readable text on a retail symbol is usually split as 1 + 5 + 5 + 1 digits.

Do I have to buy EAN-13 numbers from GS1?

For a brand selling through major retailers and marketplaces, yes: you need a company prefix registered with GS1 so the GTIN appears in GEPIR. Third-party resellers of legacy prefixes can supply numbers whose company field does not match your brand, which is a common cause of listing rejection.

Is the UPC-A check digit calculated differently?

No. UPC-A uses the identical mod-10 rule over its eleven data digits, with weight 3 on the leftmost digit. Prefix a UPC-A with a zero and it becomes a valid GTIN-13 with the same check-digit logic.

Will a barcode scanner reject a wrong check digit?

A well-configured checkout scanner rejects a symbol whose encoded check digit does not match its recomputation, which is why a mis-printed or hand-typed code usually just fails to register rather than selling the wrong item. The check digit cannot correct the error, only signal it.

Keep reading

Contact us