Last updated
What Is an EAN Barcode?
EAN (European Article Number) is the international standard for product barcodes, managed by GS1. EAN-13 (13 digits) is the most common format, used on retail products worldwide. EAN-8 (8 digits) is a shorter variant for small packages. The UPC-A barcode used in North America is technically a subset of EAN-13 (EAN-13 with a leading zero).
EAN-13 Structure
| Digits | Meaning |
|---|---|
| 1–3 | GS1 Prefix (country/company prefix assigned by GS1) |
| 4–12 | Company and product reference (assigned by the company) |
| 13 | Check digit (calculated from the first 12) |
Check Digit Calculation
The EAN-13 check digit uses a weighted sum algorithm. Multiply alternating digits by 1 and 3, sum them, then the check digit is (10 − (sum mod 10)) mod 10:
function validateEAN13(barcode) {
if (!/^\d{13}$/.test(barcode)) return false;
const digits = barcode.split('').map(Number);
const sum = digits.slice(0, 12).reduce((acc, d, i) =>
acc + d * (i % 2 === 0 ? 1 : 3), 0
);
const checkDigit = (10 - (sum % 10)) % 10;
return checkDigit === digits[12];
}
console.log(validateEAN13('4006381333931')); // true (Nivea cream)
console.log(validateEAN13('4006381333932')); // false (wrong check digit)
Common EAN Prefixes
- 000–019, 030–039, 060–139: United States and Canada (UPC)
- 300–379: France
- 400–440: Germany
- 450–459, 490–499: Japan
- 500–509: United Kingdom
- 690–699: China
- 978–979: ISBN (books)
- 977: ISSN (periodicals)