Skip to tool
ecech.
🛒 E-commerce & Pricing

The Last Digit of a Barcode Is a Checksum, Not Part of the Number

It exists so a misread fails instead of ringing up the wrong product. Type twelve digits and the thirteenth is calculated for you.

Check digit

Full number

Width

modules

Prefix

How the check digit came out

Advertisement

How the calculation works

Alternate ×1 and ×3, then round up to a multiple of ten 4×1 0×3 0×1 6×3 3×1 8×3 1×1 3×3 3×1 3×3 9×1 3×3 1 check sum = 89  →  next multiple of ten is 90  →  check digit 1 Change any single digit and the sum changes, so the scanner rejects the read instead of quietly ringing up a different product.

How to Use This Tool

Choose a symbology, type the digits without the last one, and the check digit is worked out and appended. Paste the full number instead and it is verified rather than replaced.

What the check digit is for

The final digit carries no product information. It is computed from the others: multiply them alternately by 1 and 3, add the results, and the check digit is whatever brings the total to the next multiple of ten.

For 400638133393 the weighted sum is 89, so the check digit is 1 and the full code is 4006381333931.

The point is failure behaviour. Without it, a misread digit produces a different valid-looking number and the till rings up the wrong product silently. With it, almost every misread breaks the arithmetic and the scanner simply refuses — a loud failure instead of a quiet one, which is nearly always the better design.

What it catches, and the one thing it misses

  • Any single wrong digit — always caught, because changing one digit always changes the weighted sum.
  • Most swapped adjacent digits — caught, because the two positions carry different weights.
  • Adjacent digits differing by exactly 5 — missed. Swapping them changes the sum by 2×5×(3−1) = 20, a multiple of ten, so the check digit stays the same. It is the known blind spot of this scheme.

Real scanners do not rely on the check digit alone; the bar patterns themselves are constrained enough that a bad read usually fails before the arithmetic is reached. The check digit is the last line, not the only one.

Thirteen digits in twelve positions 1st digits 2–7, left half digits 8–13, right half The first digit has no bars of its own. It is encoded in the pattern of odd and even parity across the left half — which is also how a scanner knows the label is upside down, and reads it backwards without complaint.
UPC-A is the same symbol with a leading zero, which is why every UPC is also a valid EAN-13.

Which symbology to use

  • EAN-13 — the worldwide retail standard. 95 modules wide.
  • UPC-A — 12 digits, used in North America. It is an EAN-13 with a leading zero, so every UPC-A is also a valid EAN-13 and scanners treat them interchangeably.
  • EAN-8 — 67 modules, for packages too small for a full symbol. Numbers are allocated separately and sparingly, so it is not simply a shorter EAN-13.

The leading digits are a country or organisation prefix — 978 and 979 are books, 20 to 29 are reserved for in-store use and never leave the shop. Which prefix maps to which region is shown alongside the result.

An important caveat about using these commercially

This generates a valid symbol from whatever digits you give it. It does not, and cannot, allocate you a number. Retail barcode numbers are issued by GS1 to a registered company prefix, and inventing digits produces a barcode that scans perfectly and belongs to someone else — which retailers will reject and which can collide with a real product.

For internal use, testing, or the 20–29 in-store range, make up what you like. For anything going on a shelf, get a real number first.

Advertisement

Frequently Asked Questions

What is the last digit of a barcode for?
It is a check digit, computed from the others rather than part of the product number. Multiply the digits alternately by 1 and 3, add them, and the check digit brings the total to the next multiple of ten. It makes a misread fail loudly instead of ringing up a different product.
How do you calculate an EAN-13 check digit?
Take the first twelve digits, multiply them alternately by 1 and 3 starting with 1, and add the results. The check digit is whatever brings that sum up to the next multiple of ten. For 400638133393 the sum is 89, so the check digit is 1.
Is UPC-A the same as EAN-13?
Effectively yes. A UPC-A is an EAN-13 with a leading zero, encoded identically, and scanners treat them interchangeably. The difference is historical and administrative rather than technical.
Can the check digit catch every error?
Almost. It catches any single wrong digit and most swaps of adjacent digits. The known blind spot is swapping two adjacent digits that differ by exactly 5 — that changes the weighted sum by 20, which leaves the check digit unchanged.
Can I make up my own barcode number?
For internal use, testing, or the 20–29 in-store range, yes. For anything on a retail shelf, no: numbers are issued by GS1 against a registered company prefix, and invented digits produce a barcode that scans perfectly and belongs to another company.
Why does an EAN-13 have only twelve sets of bars?
Because the first digit has no bars of its own. It is encoded in the pattern of odd and even parity across the six left-hand digits — which also lets a scanner detect that a label is upside down and read it backwards without complaint.

Related tools in E-commerce & Pricing

Browse all E-commerce & Pricing tools
The desk where ecech. tools get written: a laptop, a notebook of to-dos and a whiteboard listing the tools on the site.

Made by one person

ecech. is not a content farm. Every tool here is written and checked by hand, one at a time, by someone who wanted the tool to exist and could not find a version that showed its working.

No accounts and no sign-in, and nothing you type reaches a server — every calculation on this page runs inside your browser. The ads are served by Google and do set their own cookies, which is set out in full on the privacy page. More about the site.