EAN-13 Check Digit: How It Works, Formula & Validation

If you work with retail products, inventory systems, or barcode generation, understanding the EAN-13 check digit is important.

The check digit is the last number in an EAN-13 barcode. It helps verify that the barcode is valid and scannable.

In this guide, you'll learn what the EAN-13 check digit is, how it is calculated, how to check an EAN number, and why it matters in real-world barcode systems.

What Is an EAN-13 Check Digit?

An EAN-13 check digit is the final (13th) digit in an EAN-13 barcode.

Its purpose is error detection.

It helps barcode scanners verify whether the barcode data was entered or scanned correctly.

An EAN-13 barcode contains:

Example:

Barcode Number: 4006381333931

Without the correct check digit, the barcode may fail validation.


🚀 Need to Calculate an EAN-13 Check Digit?

Skip manual calculation. Use our free EAN-13 Check Digit Calculator to generate and verify barcode check digits instantly.

Use Free Check Digit Calculator →

Why Is the EAN-13 Check Digit Important?

The check digit EAN 13 system helps prevent common barcode errors such as:

This improves:

A wrong check digit can make a product barcode invalid.


How Does the EAN-13 Check Digit Work?

The EAN-13 check digit uses a simple mathematical formula based on the first 12 digits.

Step 1: Start with the first 12 digits

Take only the first 12 digits of your barcode. Never include the 13th digit (the check digit) in the calculation.

Example barcode: 4006381333931 → Working digits: 400638133393

Step 2: Apply the weighting formula to each digit

Digits at odd positions (1, 3, 5, 7, 9, 11) are multiplied by 1.
Digits at even positions (2, 4, 6, 8, 10, 12) are multiplied by 3.
Add all results together to get the total sum.

Position Digit Odd / Even Multiplier Result
1 4 Odd × 1 4
2 0 Even × 3 0
3 0 Odd × 1 0
4 6 Even × 3 18
5 3 Odd × 1 3
6 8 Even × 3 24
7 1 Odd × 1 1
8 3 Even × 3 9
9 3 Odd × 1 3
10 3 Even × 3 9
11 9 Odd × 1 9
12 3 Even × 3 9
Total sum 89
Check digit  =  (10 − (89 mod 10)) mod 10 1

Step 3: Apply the check digit formula

Use this formula: Check Digit = (10 − (Total mod 10)) mod 10

Total sum = 89
89 mod 10 = 9
10 − 9 = 1
Check digit = 1
Complete barcode: 4006381333931  ✓

Note: if (Total mod 10) equals 0, the check digit is 0 — do not subtract from 10 in that case.

How to Check an EAN Number

There are two ways to verify whether an EAN-13 barcode is valid — the full manual method and a faster shortcut. Both use the same Mod-10 formula.

Method 1: Strip and recalculate

This is the standard approach used in the calculation example above.

  1. Take the first 12 digits of the barcode (ignore the 13th)
  2. Apply the weighting formula and sum the results
  3. Apply the formula: Check Digit = (10 − (Total mod 10)) mod 10
  4. Compare your result to the 13th digit of the barcode — if they match, the barcode is valid

Use this when you want to understand the full calculation or when building your own validation logic in code.

Method 2: The full-13 shortcut

A faster trick — apply the same weighting formula to all 13 digits including the check digit. If the barcode is valid, the total will always be divisible by 10 (i.e. total mod 10 = 0).

Using the example from above: the 12-digit weighted sum for 400638133393 is 89. The check digit is 1, which at position 13 (odd) is multiplied by 1, giving 89 + 1 = 90. Since 90 mod 10 = 0, the full barcode 4006381333931 is valid.

Shortcut rule: Apply the weighting formula to all 13 digits.
If Total mod 10 = 0valid barcode.
If Total mod 10 ≠ 0invalid barcode — check digit is wrong or a digit was mistyped.

This is especially useful when validating barcodes in bulk — one pass through all 13 digits, no separate tracking of odd and even sums needed. It is the method used internally by most barcode scanner firmware.

Method 3: Use the free calculator

For instant validation without manual calculation, use our free Barcode Check Digit Calculator. It supports EAN-13, UPC-A, EAN-8, and ITF-14 — enter 12 digits to calculate, or 13 digits to validate. The tool shows the full step-by-step Mod-10 breakdown so you can verify the result.


EAN-13 Check Digit — Code Examples

If you are building a system that generates or validates EAN-13 barcodes programmatically, here are ready-to-use functions in JavaScript and Python. Both implement the same GS1 Mod-10 algorithm used throughout this guide.

JavaScript

Works in any browser or Node.js environment. Covers both calculation (12 digits in) and validation (13 digits in).

/**
 * Calculate the EAN-13 check digit from the first 12 digits.
 * @param {string} digits - The first 12 digits as a string.
 * @returns {number} The check digit (0–9).
 */
function calculateEAN13CheckDigit(digits) {
    if (digits.length !== 12 || !/^\d{12}$/.test(digits)) {
        throw new Error('Input must be exactly 12 numeric digits.');
    }
 
    let total = 0;
    for (let i = 0; i < 12; i++) {
        const digit = parseInt(digits[i], 10);
        const multiplier = (i % 2 === 0) ? 1 : 3;  // odd positions × 1, even × 3
        total += digit * multiplier;
    }
 
    return (10 - (total % 10)) % 10;
}
 
/**
 * Validate a full 13-digit EAN-13 barcode.
 * @param {string} barcode - The full 13-digit barcode as a string.
 * @returns {boolean} True if valid, false if not.
 */
function validateEAN13(barcode) {
    if (barcode.length !== 13 || !/^\d{13}$/.test(barcode)) {
        return false;
    }
 
    const checkDigit = calculateEAN13CheckDigit(barcode.substring(0, 12));
    return checkDigit === parseInt(barcode[12], 10);
}
 
// Examples
console.log(calculateEAN13CheckDigit('400638133393'));  // 1
console.log(validateEAN13('4006381333931'));             // true
console.log(validateEAN13('4006381333930'));             // false

Python

Compatible with Python 3.6+. The same two functions — calculate from 12 digits, or validate a full 13-digit barcode.

def calculate_ean13_check_digit(digits: str) -> int:
    """
    Calculate the EAN-13 check digit from the first 12 digits.
 
    Args:
        digits: The first 12 digits as a string.
 
    Returns:
        The check digit as an integer (0-9).
 
    Raises:
        ValueError: If input is not exactly 12 numeric digits.
    """
    if len(digits) != 12 or not digits.isdigit():
        raise ValueError('Input must be exactly 12 numeric digits.')
 
    total = sum(
        int(d) * (1 if i % 2 == 0 else 3)   # odd positions × 1, even × 3
        for i, d in enumerate(digits)
    )
 
    return (10 - (total % 10)) % 10
 
 
def validate_ean13(barcode: str) -> bool:
    """
    Validate a full 13-digit EAN-13 barcode.
 
    Args:
        barcode: The full 13-digit barcode as a string.
 
    Returns:
        True if valid, False otherwise.
    """
    if len(barcode) != 13 or not barcode.isdigit():
        return False
 
    check_digit = calculate_ean13_check_digit(barcode[:12])
    return check_digit == int(barcode[12])
 
 
# Examples
print(calculate_ean13_check_digit('400638133393'))  # 1
print(validate_ean13('4006381333931'))               # True
print(validate_ean13('4006381333930'))               # False

Both functions use the same formula explained in the step-by-step calculation above: odd-position digits (index 0, 2, 4…) × 1, even-position digits (index 1, 3, 5…) × 3, sum all results, then apply (10 − (total mod 10)) mod 10. The mod 10 wrapper on the outside handles the edge case where the total is already divisible by 10 (check digit = 0).


Example of EAN-13 Check Digit Validation

Let's validate the barcode 5901234123457. Take the first 12 digits: 590123412345 and apply the same formula.

Position Digit Odd / Even Multiplier Result
1 5 Odd × 1 5
2 9 Even × 3 27
3 0 Odd × 1 0
4 1 Even × 3 3
5 2 Odd × 1 2
6 3 Even × 3 9
7 4 Odd × 1 4
8 1 Even × 3 3
9 2 Odd × 1 2
10 3 Even × 3 9
11 4 Odd × 1 4
12 5 Even × 3 15
Total sum 83
Check digit  =  (10 − (83 mod 10)) mod 10 7
Total sum = 83
83 mod 10 = 3
10 − 3 = 7
Check digit = 7
The last digit of our barcode is 7 — the barcode 5901234123457 is valid ✓

Common Errors in EAN-13 Check Digit Calculation

Using the wrong positions

Always count positions from left to right.

Multiplying the wrong digits

Only even-position digits are multiplied by 3.

Including the check digit

Use only the first 12 digits for calculation.

Incorrect rounding

Always round up to the next multiple of 10.


Real-World Use Cases of EAN-13 Check Digits

Retail Product Packaging

Retail stores use EAN-13 barcodes for fast checkout scanning.

Inventory Management

Warehouses validate product barcodes before storing inventory.

E-commerce Product Listings

Online marketplaces use EAN numbers to identify products accurately.

Manufacturing Systems

Factories generate validated barcodes for packaging and labeling.

Logistics and Shipping

Shipping systems verify barcode data during dispatch and delivery.


Difference Between EAN-13 and UPC Check Digit

EAN-13 and UPC use similar check digit logic.

EAN is used globally, while UPC is more common in North America. Check our complete guide on EAN vs UPC Barcodes.

When Should You Verify an EAN Barcode?

You should run an EAN barcode check when:


Best Practices for EAN-13 Validation

Validate before printing

Always verify barcode data before printing labels or packaging.

Automate barcode checks

Use tools to reduce manual mistakes. Use our barcode analyzer to validate barcodes with just 1 click.

Keep product data clean

Store only validated barcode records.

Test with scanners

Validation helps, but print quality also matters.


Frequently Asked Questions

1. What is an EAN-13 check digit?

The EAN-13 check digit is the final (13th) digit in an EAN-13 barcode. It is mathematically derived from the first 12 digits using the GS1 Mod-10 algorithm and serves as an error-detection mechanism. Without a correct check digit, a barcode may fail validation or not scan correctly at point-of-sale and inventory systems.

2. How do I calculate an EAN-13 check digit?

Take the first 12 digits of your barcode. Multiply odd-position digits (positions 1, 3, 5, 7, 9, 11) by 1 and even-position digits (positions 2, 4, 6, 8, 10, 12) by 3. Sum all the results, then apply the formula: Check Digit = (10 − (Total mod 10)) mod 10. See the full step-by-step calculation table above for a worked example.

3. Can different EAN codes have the same check digit?

Yes. The check digit is not a unique identifier — it only reflects the modular arithmetic of the 12 data digits. Different barcode numbers can produce the same check digit value. Its purpose is error detection, not uniqueness.

4. What happens if the check digit is wrong?

A barcode with an incorrect check digit will fail validation and typically will not scan correctly at retail checkouts, warehouse scanners, or inventory systems. Online marketplaces such as Amazon and eBay also reject product listings with invalid EAN numbers, so getting the check digit right before printing labels is essential.

5. Is EAN-13 check digit calculation the same worldwide?

Yes. The calculation follows the global GS1 standard and is identical in every country. The same Mod-10 algorithm is used across retail, logistics, e-commerce, and manufacturing wherever EAN-13 barcodes are in use - making EAN-13 a truly universal product identification system.

6. What is the difference between calculating and validating a check digit?

Calculating means you have 12 digits and need to find the correct 13th digit. Validating means you already have a full 13-digit barcode and want to confirm the check digit is correct. For validation, apply the same formula to the first 12 digits and compare the result to the 13th digit — if they match, the barcode is valid. You can also use our free Barcode Check Digit Calculator for both operations instantly.


🚀 Need to Calculate an EAN-13 Check Digit?

Skip manual calculation. Use our free EAN-13 Check Digit Calculator to generate and verify barcode check digits instantly.

Use Free Check Digit Calculator →

EAN-13 Check Digit Guide

Final Thoughts

The EAN-13 check digit is a critical part of barcode validation.

It helps detect errors, improve scanning reliability, and maintain accurate product data across retail, logistics, and inventory systems.

Whether you create or verify barcodes, understanding the EAN 13 check digit system helps prevent costly mistakes and ensures barcode accuracy.