🔧 AI Nachrichten Major AI platforms go down in unprecedented simultaneous outage(03.09.2026 um 17:34 Uhr)
🔧 AI Nachrichten ChatGPT, Claude, and Grok Down? Users Report Widespread Outages(03.09.2026 um 19:14 Uhr)
🔧 AI Nachrichten OpenAI Launches GPT-6 Astra, Says We May Have Entered the AGI Era(03.09.2026 um 22:08 Uhr)
🔧 AI Nachrichten Claude Comes to CarPlay as Fifth Major AI Chatbot App(05.09.2026 um 05:31 Uhr)
🔧 AI Nachrichten OpenAI’s GPT-6 Astra Is AGI, Says NVIDIA CEO Jensen Huang(07.09.2026 um 06:31 Uhr)
🔧 AI Nachrichten Blame AI companies for Mac mini and Mac Studio shortage(31.08.2026 um 10:32 Uhr)
🔧 AI Nachrichten Major AI platforms go down in unprecedented simultaneous outage(03.09.2026 um 17:34 Uhr)
🔧 AI Nachrichten ChatGPT, Claude, and Grok Down? Users Report Widespread Outages(03.09.2026 um 19:14 Uhr)
🔧 AI Nachrichten OpenAI Launches GPT-6 Astra, Says We May Have Entered the AGI Era(03.09.2026 um 22:08 Uhr)
🔧 AI Nachrichten Claude Comes to CarPlay as Fifth Major AI Chatbot App(05.09.2026 um 05:31 Uhr)
🔧 AI Nachrichten OpenAI’s GPT-6 Astra Is AGI, Says NVIDIA CEO Jensen Huang(07.09.2026 um 06:31 Uhr)
🔧 AI Nachrichten Blame AI companies for Mac mini and Mac Studio shortage(31.08.2026 um 10:32 Uhr)

🔧 Programmierung 🕛 kürzlich 3 Min Lesezeit
0

How to Validate a GTIN / EAN-13 Barcode Check Digit (GS1 Mod-10, explained)

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

If you have ever uploaded a product feed to Amazon, Google Merchant Center or Shopify and been rejected with "invalid GTIN," the culprit is almost always the check digit — the last digit of the barcode. It is not random: it is calculated from all the other digits, and if it does not match, the platform rejects the code.



Here is exactly how the check digit works, with a worked example you can follow by hand.






What is a GTIN check digit?



GTIN (Global Trade Item Number) is the umbrella term for the barcodes on products: GTIN-8, UPC-A (12 digits), EAN-13 (13 digits) and GTIN-14. The final digit of every one of them is a check digit computed with the GS1 Mod-10 algorithm. Its job is to catch typos: change one digit and the check digit almost always stops matching.






The GS1 Mod-10 algorithm, step by step



Take all the digits except the last (the check digit), then:




  1. Starting from the rightmost of those digits, multiply every second digit by 3 and the rest by 1.

  2. Add up all the results.

  3. Find what you must add to reach the next multiple of 10. That number (0-9) is the check digit.



Formally: check = (10 − (sum mod 10)) mod 10.






A worked example — EAN-13 400638133393?



The first 12 digits are 4 0 0 6 3 8 1 3 3 3 9 3. Working right to left, alternate the weights ×3 and ×1:




CODE
digit:   4  0  0  6  3  8  1  3  3  3  9  3
weight: 1 3 1 3 1 3 1 3 1 3 1 3
product: 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 = (10 − 9) mod 10 = 1.



The full valid barcode is therefore 4006381333931. If a feed lists 4006381333930, it is wrong — and that is exactly the kind of error that gets a listing rejected.






In code (Python)






CODE
def gtin_check_digit(body: str) -> int:
total = 0
for i, ch in enumerate(reversed(body)):
total += int(ch) * (3 if i % 2 == 0 else 1)
return (10 - total % 10) % 10

print(gtin_check_digit("400638133393")) # -> 1






The same algorithm works for UPC-A (12), EAN-13 (13), GTIN-8 and GTIN-14 — only the length changes.






Two things that trip people up





  • Excel eats leading zeros. A UPC like 036000291452 becomes 36000291452 the moment Excel treats the cell as a number, which changes the length and breaks validation. Format the column as Text before pasting.


  • Wrong length. UPC-A is 12 digits, EAN-13 is 13. Padding a UPC with a leading zero turns it into a valid EAN-13 — that is normal, not an error.






The fast way (no math)



If you just need to check or generate a check digit right now, paste the code into a free that checks up to 100 codes per call (and also handles IBAN, EU VAT, VIN, ISIN and more). Same input, same output, every time — no AI guessing.

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
3 Quellen
GPT-6 Astra Release Today? OpenAI’s Next Major AI Model Is Almost Here
1 Quelle
Apple accuses OpenAI of destroying evidence as trade-secrets fight intensifies
1 Quelle
Major AI platforms go down in unprecedented simultaneous outage
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten How to Validate a GTIN / EAN-13 Barcode Check Digit (GS1 Mod-10, explained)

Thematisch verwandte Begriffe: Validate, GTIN, EAN13, Barcode · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...