Since 1 November 2026, parcels sent from outside the EU to EU consumers carry product identifiers for every item on the customs declaration. For Shopify stores, that means every variant shipping to the EU needs a valid standardized barcode (GTIN, UPC, EAN or ISBN) or a declaration that none exists.
"Valid" is doing a lot of work in that sentence. A catalog built over years collects barcodes with wrong check digits, dropped leading zeros, case codes from wholesale sheets and placeholder values like N/A. This post walks through the checks behind shopify-gtin-checker, an open-source CLI that audits a Shopify product export, and the edge cases that make barcode validation less trivial than it looks.
Parsing Shopify's Variant Barcodes cell
Shopify's product export now holds up to 20 barcodes per variant in a single Variant Barcodes column:
gtin:00012345678905; ns-pid:PV-NSPID-001; PV\;ESCAPE\:001
The format:
- Typed barcodes are
type:value, with lowercase type names (gtin,upc,ean,isbn,ns-pid,asin) - Barcodes are separated by
; - Untyped barcodes have no prefix
- A literal
;or:inside a value is escaped as\;or\:
Splitting on ; and : breaks on the third barcode above, which is a single untyped value: PV;ESCAPE:001. The parser walks the cell character by character instead, and only the first unescaped colon separates the type from the value:
for (let index = 0; index < cell.length; index++) {
const character = cell[index];
const next = cell[index + 1];
if (character === '\\' && (next === '\\' || next === ';' || next === ':')) {
value += next;
index++;
} else if (character === ';') {
finishBarcode();
} else if (character === ':' && type === null) {
type = value.trim();
value = '';
} else {
value += character;
}
}
The output for the example cell:
[
{ "type": "GTIN", "value": "00012345678905" },
{ "type": "NS-PID", "value": "PV-NSPID-001" },
{ "type": "CUSTOM", "value": "PV;ESCAPE:001" }
]
Type names are normalized to uppercase, NS_PID and NSPID map to NS-PID, and a missing type becomes CUSTOM, which is what Shopify calls an untyped barcode.
The GS1 check digit
GTIN-8, GTIN-12 (UPC-A), GTIN-13 (EAN-13) and GTIN-14 all share 1 check digit algorithm. Counting from the right, the check digit has weight 1, then the weights alternate 3, 1, 3, 1. A code is valid when the weighted sum is a multiple of 10:
const GTIN_LENGTHS = new Set([8, 12, 13, 14]);
function isValidGtin(value) {
if (!GTIN_LENGTHS.has(value.length) || /[^0-9]/.test(value)) return false;
let sum = 0;
let weight = 1;
for (let index = value.length - 1; index >= 0; index--) {
sum += Number(value[index]) * weight;
weight = 4 - weight;
}
return sum % 10 === 0;
}
weight = 4 - weight flips between 1 and 3. Because the weights are anchored to the right, leading zeros don't change the sum, so 012345678905 and 00012345678905 both validate, and they're the same GTIN.
That property drives duplicate detection. Every standardized barcode is padded to 14 digits before comparison, so a UPC stored as 12 digits on 1 variant and as 14 on another shows up as a duplicate:
const gtin = identifier.gtin.padStart(14, '0');
14 digits doesn't mean case code
A GTIN-14 often identifies a packaging level, like a case of 12, rather than the item a customer receives. Wholesale price lists mix them in, and the case code then ends up in the store's barcode field.
The first digit of a GTIN-14, the indicator digit, tells them apart:
| Indicator digit | Meaning |
|---|---|
| 0 | A GTIN-8, 12 or 13 padded with zeros: a normal item barcode |
| 1 to 8 | A packaging level, so a possible case code |
| 9 | A variable-measure item, usually sold by weight |
Flagging every 14-digit code as a case code would bury real findings under false ones, since padded item barcodes are common. The checker only warns on indicators 1 to 9:
if (value.length === 14 && /^[1-8]/.test(value)) {
// possible case code
} else if (value.length === 14 && value.startsWith('9')) {
// variable-measure code
}
UPC-E: the 8-digit code that fails as GTIN-8
UPC-E is a compressed 8-digit form of a 12-digit UPC-A, used on small packaging. Its check digit belongs to the expanded UPC-A, so running an 8-digit UPC-E through the GTIN-8 check gives the wrong answer:
| Code | As GTIN-8 | Expanded UPC-A | As UPC-A |
|---|---|---|---|
04252614 |
Invalid | 042100005264 |
Valid |
Expansion depends on the 6th digit of the compressed code:
function expandUpcE(value) {
if (value.length !== 8 || !/^[01][0-9]{7}$/.test(value)) return null;
const [system, first, second, third, fourth, fifth, compression, check] = value;
const prefix = `${system}${first}${second}`;
if (compression <= '2') return `${prefix}${compression}0000${third}${fourth}${fifth}${check}`;
if (compression === '3') return `${prefix}${third}00000${fourth}${fifth}${check}`;
if (compression === '4') return `${prefix}${third}${fourth}00000${fifth}${check}`;
return `${prefix}${third}${fourth}${fifth}0000${compression}${check}`;
}
Only number systems 0 and 1 are valid for UPC-E, which the regex enforces. A barcode typed upc with 8 digits is expanded and then validated as UPC-A. An untyped 8-digit value that fails as GTIN-8 but passes after expansion gets a "Possible UPC-E" warning, since setting its type to UPC is what makes it count.
ISBN-10 and the mod 11 check
Older books carry a 10-digit ISBN with a different algorithm: weights 10 down to 1, a sum that must be divisible by 11, and X standing for 10 in the check position:
function isValidIsbn10(value) {
if (value.length !== 10 || !/^[0-9]{9}[0-9X]$/i.test(value)) return false;
let sum = 0;
for (let index = 0; index < 10; index++) {
const digit = value[index].toUpperCase() === 'X' ? 10 : Number(value[index]);
sum += digit * (10 - index);
}
return sum % 11 === 0;
}
A 13-digit ISBN is an EAN-13 starting with 978 or 979, so it goes through the GS1 check.
Untyped barcodes still count
For EU labels, Shopify takes the standardized identifier from the first GTIN, UPC, EAN or ISBN barcode, or from an untyped barcode that is a valid GTIN or ISBN. The checker mirrors that rule: an untyped valid GTIN satisfies the check and only gets an info-level note suggesting the gtin type, because tools outside Shopify may only read typed barcodes.
Every finding carries 1 of 3 levels:
| Level | Examples |
|---|---|
| Problem | Invalid check digit, no standardized barcode |
| Warning | Possible case code, missing leading zero, possible UPC-E, placeholder, duplicate |
| Info | Untyped valid GTIN |
Running it
On a Shopify product export, with Node.js 20 or newer:
npx @promptlounge/shopify-gtin-checker products_export_1.csv
The summary prints to the terminal, and a CSV with 1 row per finding is saved next to the export. Everything runs locally.
The check functions in src/gtin.js, src/barcodes.js and src/check.js have no dependencies, so they also run in an n8n Code node, fed by the Shopify node or by the Admin GraphQL API for typed barcodes. The n8n example covers both setups, including pagination.
Links
- Source and issues: github.com/PromptLounge/shopify-gtin-checker
- Package: @promptlounge/shopify-gtin-checker on npm
- For store owners, reading the export without code: How to Check EU Product Identifiers in a Shopify Product Export
Top comments (0)