GS1
Check GTIN, SSCC and GLN identifiers, compute their check digit, and read or write GS1-128, GS1 DataMatrix and GS1 QR element strings. Typical uses: read the data of a logistic label or medicine box, build the content of a shipping label.
type is_gtin <value>
Description
A GTIN-8, 12, 13 or 14 with a right check digit: 1 or 0. Spaces and hyphens are ignored. It gives the same result as type is_ean, under the GS1 name
A GTIN-8, 12, 13 or 14 with a right check digit: 1 or 0. Spaces and hyphens are ignored. It gives the same result as type is_ean, under the GS1 name
Parameters
value: The number - String - required
value: The number - String - required
admin
type is_gtin "09501101530003"
mentdb
1
bad
admin
type is_gtin "09501101530004"
mentdb
0
type is_sscc <value>
Description
An SSCC, 18 digits with a right check digit: 1 or 0
An SSCC, 18 digits with a right check digit: 1 or 0
Parameters
value: The number - String - required
value: The number - String - required
admin
type is_sscc "106141411234567897"
mentdb
1
bad
admin
type is_sscc "106141411234567890"
mentdb
0
Used in use cases (1 recipe)
Integrator & ETL developer › Read a GS1 logistic label and write the next one
Integrator & ETL developer › Read a GS1 logistic label and write the next one
type is_gln <value>
Description
A GLN, 13 digits with a right check digit: 1 or 0
A GLN, 13 digits with a right check digit: 1 or 0
Parameters
value: The number - String - required
value: The number - String - required
admin
type is_gln "0614141000012"
mentdb
1
bad
admin
type is_gln "0614141000013"
mentdb
0
gs1 check_digit <digits>
Description
The mod 10 check digit of a number given without it, 1 to 17 digits
The mod 10 check digit of a number given without it, 1 to 17 digits
Parameters
digits: The digits - String - required
digits: The digits - String - required
admin
gs1 check_digit "950110153000"
mentdb
3
Used in use cases (1 recipe)
Integrator & ETL developer › Read a GS1 logistic label and write the next one
Integrator & ETL developer › Read a GS1 logistic label and write the next one
gs1 parse <element_string>
Description
Read an element string. Returns {valid, element_string, elements: [{ai, title, value, check_digit_ok, date, decimal, unit, currency_numeric}], errors}. A value that does not fit its format, a bad check digit or a bad date gives valid false and a line in errors; only a text that cannot be cut in elements is an error of the function
Read an element string. Returns {valid, element_string, elements: [{ai, title, value, check_digit_ok, date, decimal, unit, currency_numeric}], errors}. A value that does not fit its format, a bad check digit or a bad date gives valid false and a line in errors; only a text that cannot be cut in elements is an error of the function
Parameters
element_string: The element string - String - required
element_string: The element string - String - required
admin
gs1 parse "(01)09501101530003(17)261231(10)ABC123"
mentdb
{"valid": true, "element_string": "(01)09501101530003(17)261231(10)ABC123", "elements": [{"ai": "01", "title": "GTIN", "value": "09501101530003", "check_digit_ok": true}, {"ai": "17", "title": "USE BY OR EXPIRY", "value": "261231", "date": "2026-12-31"}, {"ai": "10", "title": "BATCH/LOT", "value": "ABC123"}], "errors": []}
as a reader gives it, with an exact weight and a GS separator
admin
gs1 parse "]C101095011015300033103001250<GS>21SER1"
mentdb
{"valid": true, "element_string": "(01)09501101530003(3103)001250(21)SER1", "elements": [{"ai": "01", "title": "GTIN", "value": "09501101530003", "check_digit_ok": true}, {"ai": "3103", "title": "NET WEIGHT", "value": "001250", "decimal": "1.250", "unit": "kg"}, {"ai": "21", "title": "SERIAL", "value": "SER1"}], "errors": []}
a bad check digit
admin
gs1 parse "(00)106141411234567890"
mentdb
{"valid": false, "element_string": "(00)106141411234567890", "elements": [{"ai": "00", "title": "SSCC", "value": "106141411234567890", "check_digit_ok": false}], "errors": ["AI (00): bad check digit"]}
gs1 parse <element_string> <params>
Description
Read with parameters: separator (a text that stands for the GS character), now (the date around which the century of a two-digit year is chosen)
Read with parameters: separator (a text that stands for the GS character), now (the date around which the century of a two-digit year is chosen)
Parameters
element_string: The element string - String - required
params: The parameters as JSON - String - required
element_string: The element string - String - required
params: The parameters as JSON - String - required
admin
gs1 parse "0109501101530003|10LOT1|21S1" "{\"separator\": \"|\"}"
mentdb
{"valid": true, "element_string": "(01)09501101530003(10)LOT1(21)S1", "elements": [{"ai": "01", "title": "GTIN", "value": "09501101530003", "check_digit_ok": true}, {"ai": "10", "title": "BATCH/LOT", "value": "LOT1"}, {"ai": "21", "title": "SERIAL", "value": "S1"}], "errors": []}
day 00 and a fixed date
admin
gs1 parse "(15)260200" "{\"now\": \"2026-11-05\"}"
mentdb
{"valid": true, "element_string": "(15)260200", "elements": [{"ai": "15", "title": "BEST BEFORE", "value": "260200", "day_unspecified": true, "date": "2026-02-28"}], "errors": []}
Used in use cases (1 recipe)
Integrator & ETL developer › Read a GS1 logistic label and write the next one
Integrator & ETL developer › Read a GS1 logistic label and write the next one
gs1 build <elements>
Description
Write an element string from {ai: value} or [{ai, value}]. A field with decimals can be given as 1.25: it is padded and exact, and more decimals than the AI allows is an error. A variable-length field with decimals (390n, 392n) must have its point: 12 for AI 3902 is refused, as these digits would mean 0.12. A fixed-length field (3103) can also hold its raw digits, 001250. The values are checked as in gs1 parse. Returns {element_string, barcode_data, length}: barcode_data holds a GS character only where the specification needs one
Write an element string from {ai: value} or [{ai, value}]. A field with decimals can be given as 1.25: it is padded and exact, and more decimals than the AI allows is an error. A variable-length field with decimals (390n, 392n) must have its point: 12 for AI 3902 is refused, as these digits would mean 0.12. A fixed-length field (3103) can also hold its raw digits, 001250. The values are checked as in gs1 parse. Returns {element_string, barcode_data, length}: barcode_data holds a GS character only where the specification needs one
Parameters
elements: The fields, in the order of the code - String - required
elements: The fields, in the order of the code - String - required
admin
gs1 build "{\"01\": \"09501101530003\", \"3103\": \"1.25\", \"17\": \"261231\", \"10\": \"ABC123\", \"21\": \"S1\"}"
mentdb
{"element_string": "(01)09501101530003(3103)001250(17)261231(10)ABC123(21)S1", "barcode_data": "010950110153000331030012501726123110ABC123\u001D21S1", "length": 47}
gs1 build <elements> <params>
Description
Write with the parameter now (the date window of the checked dates)
Write with the parameter now (the date window of the checked dates)
Parameters
elements: The fields, in the order of the code - String - required
params: The parameters as JSON - String - required
elements: The fields, in the order of the code - String - required
params: The parameters as JSON - String - required
admin
gs1 build "[{\"ai\": \"00\", \"value\": \"106141411234567897\"}, {\"ai\": \"400\", \"value\": \"PO-77\"}]" "{\"now\": \"2026-11-05\"}"
mentdb
{"element_string": "(00)106141411234567897(400)PO-77", "barcode_data": "00106141411234567897400PO-77", "length": 28}
Used in use cases (1 recipe)
Integrator & ETL developer › Read a GS1 logistic label and write the next one
Integrator & ETL developer › Read a GS1 logistic label and write the next one
