Data integrity

Barcode Check Digits Explained

A check digit is a calculated character added to data so software or a scanner can detect many common transcription and encoding errors.

What a check digit does

A check digit is calculated from the other characters in an identifier. When the barcode is read, the receiving system can perform the same calculation and compare the result. If the calculated value does not match the encoded check digit, the data is considered invalid.

This is error detection, not encryption and not a guarantee that the identifier was assigned correctly.

GTIN check digits

GS1 identifiers such as GTIN-12, GTIN-13 and GTIN-14 use a Modulo-10 check digit. Starting from the rightmost data digit and moving left, the algorithm applies alternating weights of 3 and 1, totals the products, and chooses the check digit that brings the total to the next multiple of ten.

Example: The check digit is part of the GTIN itself. It should be calculated from the identifier data—not chosen independently.

Check digits versus symbology check characters

It is useful to separate an identifier check digit from a symbology check character. Code 128 includes a mandatory internal symbol check character calculated from codeword values. Code 39 can use an optional Modulo-43 check character in some applications. UPC/EAN visually encode the GTIN check digit as part of the data.

These mechanisms operate at different layers: one may validate the business identifier, while another validates the barcode symbol encoding.

What errors can be detected?

Well-designed check-digit algorithms detect many single-digit errors and many transposition errors, which are among the most common human entry mistakes. They do not prove that the correct item number was assigned, and two different valid identifiers will naturally have different valid check digits.

Implementation advice

  • Store the full business identifier consistently, including its check digit when the standard defines it as part of the identifier.
  • Use a tested library or central function to calculate check digits.
  • Validate incoming identifiers before saving them.
  • Do not confuse a scanner-generated symbology identifier with a check digit.
  • When building GS1 data, validate Application Identifier field lengths in addition to check digits.

Reference

Continue learning