EAN-13
An EAN-13 is the 13-digit number under most shop barcodes. Every one the program makes starts with 952, a prefix GS1 keeps for examples.
What an EAN-13 is
Thirteen digits, the last of which is the check digit. GS1 calls it GTIN-13. The first digits are the GS1 prefix of the organisation that issued the number, and an ISBN is the same kind of number under the prefix 978 or 979.
The check digit
Counting from the right, multiply the digit next to the check digit by 3, the one before it by 1, and so on in turn. Add up the products and subtract the total from the nearest multiple of 10 that is equal or higher. The difference is the check digit.
For 13 digits this is the same as weights 1 and 3 from the left, which is how the ISBN manual puts it. GS1 counts from the right because its longer numbers line up on the right.
Valid EAN-13 numbers for your tests
$ qadg quick ean --count 5 --seed example 9529353000464 9527337928292 9529619873306 9529970898819 9522548903670
GS1 keeps the prefix 952 for demonstrations and examples of the GS1 system and puts its own examples there, so no product is given a number under it. GS1 set the prefix aside in its January 2023 release, and its specification does not say whether any company was given a number there before.
What your application should do with a broken one
Refuse a number whose check digit does not match. A changed digit always shows. Swapping two neighbouring digits that differ by 5 does not, so the program does not count such a swap as damage and says so in the manifest.
Broken ones for your tests
The recipe below makes 100 values and asks for damage in 20% of the rows. Download it and run it as it is, then change the count or the share to fit your tests.
The recipe
# EAN-13 numbers for testing, with one broken value asked for in about a fifth
# of the rows.
#
# Every EAN starts with 952, which GS1 sets aside for examples. The damage
# changes a digit or swaps two, and the manifest says your application should
# reject each one. It also lists the damage this build could not carry out, with
# the reason.
#
# qadg generate ean.yaml
#
# writes product.csv, expectation-manifest.json and run-note.json. The same seed
# breaks the same values on every machine.
version: "0.1"
seed: "ean"
locale: en-US
entities:
product:
count: 100
fields:
ean: { generator: ean }
policy:
layers: [L3]
rows: 20%
per_row: exactly_one
output:
format: csv
Run it
Save the recipe, then run this in the same folder. This is what the program printed for it.
$ qadg generate ean.yaml product: 100 rows, 1 column 1 table, 100 rows written 25 defects ordered, 6 applied, manifest in expectation-manifest.json 19 defects could not be applied, and the manifest carries the reason for each one 4 because this run lacks something they need, and the manifest says what for each one 15 because this build has no implementation of them yet
What it damaged
The recipe ordered 25 defects, and this build applied the 6 below. The other 19 are in the manifest as not applied, each with its reason, and the run above counts them by reason.
L3.checksum.off_by_onerejectproduct 30, column ean
9526176182025 → 9526176182026
L3.checksum.transposed_digitsrejectproduct 33, column ean
9524647778685 → 9524674778685
L3.checksum.off_by_onerejectproduct 50, column ean
9521118496840 → 9521118496841
L3.checksum.transposed_digitsrejectproduct 69, column ean
9524004060194 → 9254004060194
L3.checksum.off_by_onerejectproduct 81, column ean
9528479916284 → 9528479916285
L3.checksum.transposed_digitsrejectproduct 87, column ean
9527816461852 → 9527816641852
Sources
- GS1 General Specifications, Release 26.0, January 2026: tables 1-4 and 1-5 for the prefix 952, table 7-8 for the check digit.
- International ISBN Agency, ISBN Users’ Manual, appendix A1.1.