How Barcode Check Digits Work, and Why the Last Number Matters
Look at the numbers printed underneath any retail barcode and you'll notice the last digit doesn't seem to belong to whatever product identifier the rest of the number represents. That's because it doesn't, not in the way the other digits do. It's a check digit, a number mathematically derived from everything before it, and its entire job is to catch mistakes before they turn into a wrong price at the till or a shipment sent to the wrong warehouse.
A barcode check digit is the final digit, calculated from the preceding digits using a weighted sum formula specific to that barcode format. A scanner recalculates the formula from what it just read and compares it to the printed check digit. A mismatch means the scan failed, catching printing errors and misreads before they reach the till or the warehouse system.
How is a UPC-A check digit actually calculated?
Take the UPC-A code, the standard on most retail products sold in North America. It encodes 12 digits: the first identifies the product category, the next five identify the manufacturer, the following five identify the specific product, and the final digit, the check digit, is calculated from the previous eleven using a weighted sum. Each digit in an alternating pattern is multiplied by either 3 or 1, the results are added together, and the check digit is whatever value brings that total to the next exact multiple of 10.
If you scan a barcode and the computed check digit doesn't match the stored one, the scanner knows immediately that something has gone wrong in the reading or printing. It rejects the scan and asks you to try again, rather than silently recording whatever garbled number it happened to read.
Why does the rest of the world use EAN-13 instead?
The UPC-A works well in North America, but the rest of the world needed one more digit. The European Article Number, EAN-13, extends the format to thirteen digits, with the first two or three identifying the country or region of the issuing organisation. The barcode on a book in a French bookshop, a German pharmacy, and an Australian supermarket all use EAN-13. It's the same underlying technology and the same check digit principle, just slightly wider to accommodate a global numbering scheme rather than a national one.
Do other barcode formats use the same trick?
Retail barcodes are the visible surface of a much larger ecosystem of one-dimensional codes, and most of them borrow the same check-digit idea with their own specific formula. Code 128 is the workhorse of logistics, found on postal labels and shipping documents because it can encode the full ASCII character set rather than just digits. ITF-14 is designed for corrugated cardboard shipping cartons, where coarser printing demands a more robust format. Code 39, one of the earliest alphanumeric barcodes, is self-checking by design and doesn't rely on an external check digit at all, which is part of why it remains common in industrial and military applications where a simpler validation approach is preferred.
What happens physically when a scanner reads a barcode?
A barcode is, at its core, a method of encoding numbers as patterns of light and dark, a visual representation of binary. When a laser scanner passes over a barcode, it measures how much light is reflected back. Dark bars absorb light, white spaces reflect it, and the rapid alternation between reflection and absorption produces a pattern of electrical pulses that the scanner's decoder translates into a sequence of bits, and then into digits, at which point the check digit calculation runs automatically before the result is accepted.
Do I need to calculate the check digit myself?
No. A properly built barcode generator calculates and appends the correct check digit automatically for whatever format you're generating, whether that's UPC-A, EAN-13, Code 128, ITF-14 or one of the other common retail and logistics formats. The barcode generator on this site handles this for nine different formats, producing scannable PNG and SVG output with the check digit calculated correctly every time.
Frequently Asked Questions
What is a barcode check digit?
It's the final digit of a barcode, calculated from all the digits before it using a weighted sum formula. A scanner recalculates that formula from the digits it just read and compares the result to the check digit. If they don't match, the scan is rejected instead of recording the wrong product.
How is the UPC-A check digit actually calculated?
Each of the first 11 digits is multiplied by an alternating weight of 3 and 1, the results are summed, and the check digit is whatever number, when added to that sum, brings the total to the next multiple of 10.
What's the difference between UPC-A and EAN-13?
UPC-A encodes 12 digits and is the standard on most retail products in North America. EAN-13 extends the same underlying idea to 13 digits, with the extra leading digits identifying the country or region of the issuing organisation, and is used almost everywhere else in the world.
Why can't a barcode just be misread without anyone noticing?
It can, briefly, but the check digit catches almost all misreads immediately. A single misread digit will, with very high probability, produce a check digit mismatch, causing the scanner to reject the read and prompt a rescan rather than silently recording the wrong product or price.
Do all barcode formats use the same check digit formula?
No. UPC-A, EAN-13, Code 128 and ITF-14 each use their own specific weighting and calculation, though the underlying principle, a final digit mathematically derived from the rest, is shared across nearly all of them.
Can I generate barcodes with the check digit calculated automatically?
Yes. A proper barcode generator calculates and appends the correct check digit for the format you choose, so you never need to work out the formula by hand.