The last digit of a barcode
EAN-13 is the barcode on almost every retail product outside North America (and inside it, as GTIN-13). Its 13 digits are a GS1 company prefix, a product reference and a final check digit that scanners use to catch misreads. When you design packaging, list products on marketplaces or import a catalogue, a wrong check digit means the barcode will be rejected.
How it is calculated
Take the first 12 digits. Starting from the right, multiply them alternately by 3 and 1, and add the results. The check digit is the number you must add to reach the next multiple of 10.
Worked example
GS1's own example, 400638133393: from the right, 3×3 + 9×1 + 3×3 + 3×1 + 3×3 + 1×1 + 8×3 + 3×1 + 6×3 + 0×1 + 0×3 + 4×1 = 89. The next multiple of 10 is 90, so the check digit is 1 and the full code is 4006381333931.
Codes starting with 789 or 790 were issued in Brazil, 400–440 in Germany, 978–979 are books.
How this works
The page removes spaces and hyphens. With 12 digits it computes the check digit with the GS1 mod-10 algorithm: from the right, digits are weighted 3, 1, 3, 1…, summed, and the check digit is (10 − sum mod 10) mod 10. With 13 digits it recomputes the check digit from the first 12 and compares it with the last. The same algorithm is used for UPC, GTIN-14 and ISBN-13. Everything runs in your browser.
Frequently asked
Does a valid check digit mean the product is registered?
No. Only GS1 registration makes a barcode official; the check digit just catches typos and misreads.
What is the difference between EAN-13 and UPC-A?
UPC-A has 12 digits and is used in the US and Canada. Adding a leading 0 turns it into an EAN-13 with the same check digit.
What do the first digits mean?
The GS1 prefix of the member organisation that issued the company number, such as 789 for Brazil. It does not prove where the product was made.
Can I make up an EAN for my product?
Retailers and marketplaces require codes licensed from GS1. Made-up codes may clash with real products.
Sources
- GS1 General Specifications — check digit calculation (§7.9)
- ISO/IEC 7812-1:2017 — Identification cards, numbering system (Luhn check digit)
- Wikipedia — International Article Number
Reviewed Oct 17, 2026 · test vectors fixtures/codes/ean-13-check-digit/