To validate a GTIN, keep it as text, remove only explicitly allowed separators, check its length, then recalculate the last digit using the GS1 algorithm. This success, however, only proves the code's mathematical consistency. It demonstrates neither that the number was assigned by GS1, nor that it belongs to the stated brand, nor that it matches the right size or lot. A reliable check therefore involves three separate verdicts: syntax and check digit, verifiable existence or attribution, and finally a match with the observed product. Conflating these levels is precisely what creates the false positives that pollute supplier matching.
The three questions a single boolean cannot answer
A gtin_valid=true field is too vague. You need to know what was actually tested. A number can pass the check digit while having been generated at random: for many digit sequences, there mechanically exists a last digit that makes the whole thing consistent. Conversely, a genuine code can be degraded by a spreadsheet that strips a leading zero or displays it in scientific notation.
So separate the following states:
| Level | Question | Acceptable proof | What the result does NOT prove |
|---|---|---|---|
| Format | Does the value have an accepted GTIN length and only digits? | Raw string and length rule | Official attribution |
| Check digit | Does the last digit match the GS1 calculation? | Reproducible recalculation | The product's existence |
| Identity | Is the code linked to the right trade item? | Brand source, packaging, or authorized registry | Current price and stock |
GS1 defines the GTIN as a trade item identifier. Its official check digit calculator tool explains that the last digit is a key used to verify that the number is correctly composed. This wording matters: a correct check digit validates the composition, not the entire commercial history of the number.
Recalculating the check digit step by step
Take the full value as a string. The last digit is the announced check digit; the preceding digits form the body to be checked. Starting from the right of the body, alternately multiply the digits by 3 then by 1. Add up the products. The calculated check digit is the digit that completes this sum up to the next multiple of ten; if the sum is already a multiple of ten, the check digit is zero.
Here is a purely illustrative example whose digits are hypothetical, not a real product. For the body 123456789012, the products read from the right are weighted 3, 1, 3, 1, and so on. The resulting sum is 92. The complement to the next multiple of ten is 8: the hypothetical full code would therefore be 1234567890128. The calculation can also be reproduced with the formula (10 - (sum modulo 10)) modulo 10.
Control procedure:
1. Read the cell without numeric conversion. 2. Remove surrounding whitespace, but log any other correction. 3. Reject letters, remaining punctuation, and decimals added by a spreadsheet. 4. Check that the length matches a GTIN form expected in this feed. 5. Separate the announced check digit from the body. 6. Calculate the weighted sum from the right. 7. Compare the calculated check digit to the announced check digit. 8. Keep the exact reason on record in case of rejection.
Normalizing to fourteen digits can be useful for comparing GS1 exchanges, but it must be done in a derived column. The source value stays intact. GS1 notes in particular that its XML messages use a fourteen-digit representation with leading zeros, while other exchanges may use a variable length of up to fourteen digits.
Preventing identity false positives
After the check digit, the business-level part remains. According to GS1, a GTIN can only be assigned to a single product, and variations that distinguish trade items — for example model, color, size, or presentation — receive distinct references. If two rows use the same code for two different sizes, you should not arbitrarily pick the closest match. Place the rows in a review queue and look for official proof.
The proof can come from a brand listing, readable packaging, an authorized supplier feed, or a relevant GS1 service depending on access rights. Simple repetition across multiple stores is not enough: stores can copy the same error. The method for detecting GTIN duplicates between variants helps isolate these conflicts before they become matches.
Also don't confuse GTIN and SKU. The SKU is generally a reference specific to a seller or supplier. It can supplement the proof and stabilize updates, but it is not interchangeable with a GS1 identifier. Keep both columns, along with their provenance.
Allowed corrections must remain visible
A string with surrounding spaces can be cleaned without changing its meaning, provided the raw value is kept. On the other hand, blindly padding a short code, removing a digit, replacing a letter "O" with zero, or extracting the first digits from a text are risky transformations. They can produce a code that passes the algorithm while never having actually existed.
Adopt explicit statuses: valid_check_digit, invalid_check_digit, unexpected_format, missing, and ambiguous_after_correction. Then add an independent status for the match: product_confirmed, variant_conflict, or unverified. This modeling prevents a technical success from becoming, through a shortcut, a commercial approval.
To then compare offers, use only rows whose identity is sufficiently established. The procedure for comparing two suppliers on the same EAN begins precisely with this proof, not with the lowest price.
Checklist before accepting a GTIN
- The raw value has been kept as text.
- No leading zero has been lost.
- Any corrections are tracked separately.
- The expected length is documented for the feed.
- The check digit was recalculated, not just copied.
- The mathematical result is kept distinct from attribution.
- Brand, variant, and presentation match.
- Contradictory duplicates are placed in review.
- The source SKU remains available for audit.
- A rejection includes an actionable reason.
What ArbitragePro+ can automate / what the seller must verify
The proposed validateur-gtin specification could preserve the raw string, apply the GS1 calculation, assign a rejection reason, and detect conflicts between variants. It should display check-digit validity and the identity proof level separately.
The seller must verify attribution and matching against an authorized source, resolve brand or packaging conflicts, and never publish a match based solely on the algorithm.
Verify an identifier in the context of the product
Open ArbitragePro+ search to review the available matches and their associated information.
Official sources
- GS1, «Check Digit Calculator», https://www.gs1.org/services/check-digit-calculator — accessed 2026-08-17.
- GS1, «Global Trade Item Number (GTIN)», https://www.gs1.org/standards/id-keys/gtin — accessed 2026-08-17.
- GS1 Support, «How do GS1 GTINs and barcodes work?», https://support.gs1.org/support/solutions/articles/43000734095-how-do-gs1-gtins-and-barcodes-work- — accessed 2026-08-17.
- GS1 Support, «Required format of GTIN in GS1 EDI standards», https://support.gs1.org/support/solutions/articles/43000734355-what-is-the-required-format-of-gtin-in-gs1-edi-standards- — accessed 2026-08-17.
