How to Compute an EAN-13, UPC-A, or EAN-8 Check Digit — and Catch Typos Before the Label Prints
A practical guide to the GS1 mod-10 check digit algorithm. Includes a worked example, common mistakes, and the fastest way to verify a barcode before it reaches your label printer or product feed.
How to Compute an EAN-13, UPC-A, or EAN-8 Check Digit — and Catch Typos Before the Label Prints
A single wrong digit in a barcode can stop a shipment, bounce a product feed, or generate an unscannable label. The last digit of every GS1 barcode is not arbitrary — it is a check digit computed from the ones before it, and it exists specifically to catch that kind of error. Understanding how it works takes about five minutes, and once you do, a mis-keyed number never makes it to the printer.
What the Check Digit Actually Does
The GS1 mod-10 algorithm (also called Luhn mod-10 or the UPC check character formula) guarantees that every single-digit error changes the check digit. According to the GS1 General Specifications, it also catches the majority of adjacent-digit transposition errors — the two most common mistakes when a person types a 12- or 13-digit number at a keyboard.
Put differently: if you paste a complete barcode into a validator and it passes, you know there is no single mistyped character. If it fails, there is almost certainly a keying error. That is a strong guarantee for one digit of overhead.
The check digit does not prove the barcode is registered with GS1 or that it belongs to a real product. A made-up number can still pass the checksum. Passing means well-formed, not genuine.
The Algorithm: Three Steps, One Digit
The formula is the same for EAN-13, UPC-A, and EAN-8. Only the input length changes.
Step 1. Write out the body digits (everything except the check digit) and number them from right to left, starting at position 1.
Step 2. Multiply each digit by its weight: position 1 gets weight 3, position 2 gets weight 1, position 3 gets weight 3, and so on, alternating.
Step 3. Sum all the products. The check digit is the smallest non-negative integer that makes the total a multiple of 10. In practice, that is (10 - (sum mod 10)) mod 10.
Worked example: EAN-13 body 400638133393
GS1 numbers each digit from left (position 1) to the rightmost body digit (position 12), applying weight 1 to odd positions and weight 3 to even positions:
Body digits (left→right): 4 0 0 6 3 8 1 3 3 3 9 3
Weights (1,3 alternating): 1 3 1 3 1 3 1 3 1 3 1 3
Products: 4 0 0 18 3 24 1 9 3 9 9 9
Sum = 4 + 0 + 0 + 18 + 3 + 24 + 1 + 9 + 3 + 9 + 9 + 9 = 89
89 mod 10 = 9, so check digit = 10 − 9 = 1. The completed barcode is 4006381333931.
To verify: paste 4006381333931 into the EAN / UPC Check Digit Calculator — it recomputes from the first 12 digits and confirms the last digit matches.
EAN-13, UPC-A, EAN-8: One Formula, Three Lengths
All three formats run through the same mod-10 weighting. The only difference is how many body digits you feed in:
| Format | Body digits | Full length | Typical use | |--------|------------|-------------|-------------| | EAN-13 | 12 | 13 | Retail products worldwide | | UPC-A | 11 | 12 | North American retail | | EAN-8 | 7 | 8 | Small packs (gum, batteries) |
The EAN / UPC Check Digit Calculator picks the symbology for you based on how many digits you enter — no dropdown required.
UPC-A is a subset of EAN-13. Every UPC-A becomes an EAN-13 by prepending a 0. The check digit is identical either way, so you can verify this yourself: body 07155330 gives check digit 3 for EAN-8, while body 071553300003 gives check digit 3 for EAN-13 when the prefix is 0 and the rest matches. If your North American supplier sends UPC-A codes and your European platform expects EAN-13, just prefix a zero — the math stays the same.
Three Situations Where This Saves Real Time
Before sending artwork to print. Label artwork goes to the printer with a 12-digit GTIN body, but the font needs the full 13-digit EAN-13. Compute the check digit, drop the result into the artwork, and the barcode renders correctly. Getting it wrong means a reprint and a delay.
Cleaning a product feed before upload. I once inherited a spreadsheet of 4,000 GTINs destined for a marketplace upload. Three rows had check-digit failures — two transposed digits and one copy-paste that added an extra character. Running each code through the calculator before the feed went live caught all three before any listing got rejected. The alternative was debugging a marketplace rejection error with no clear pointer to which row caused it.
Teaching the algorithm to a new team member. The calculator prints the weighted sum alongside the result. You can point at each step: "See how the rightmost digit gets weight 3, not weight 1? Change that digit by 1 and the sum shifts by 3, which is enough to change the check digit." Showing the arithmetic live makes the error-catching property concrete in a way a text description alone does not.
Common Mistakes
Including the check digit when computing. EAN-13 compute mode wants 12 body digits. Pasting all 13 feeds the algorithm an extra digit and returns the check digit for a longer, wrong number. Use verify mode when you have a complete code.
Weighting from the left instead of the right. The alternating 3-1 pattern must start at the rightmost body digit. Counting from the left gives the wrong answer on all inputs where the body length is even — which is every EAN-13 body, since 12 is even. A wrong-direction implementation produces check digits that look plausible but fail on a scanner.
Assuming a pass proves the code is registered. A well-formed number and a registered GTIN are different things. The checksum only says the arithmetic works out; it says nothing about GS1 licensing.
Beyond Check Digits: Related Tools
If you are generating barcodes rather than just computing check digits, the Barcode Generator renders Code 128, EAN-13, UPC-A, and Code 39 as downloadable SVG or PNG directly in the browser.
For other check-digit schemes — credit card numbers use the Luhn algorithm, which is a close relative of the mod-10 approach but weights from the left — the Luhn Validator handles those.
Both run entirely offline in your browser, same as the EAN / UPC calculator. No file upload, no server request.
Made by Toolora · Updated 2026-06-10