Gs1 element string parse
gs1-element-string-parse · version 1.0.0 · Identifiers & check digits · free, no key needed
Parse a bracketed or FNC1-separated GS1 element string into typed AI fields: implied decimals, dates and check digits.
Use when you need to: parse a gs1 element string · decode gs1-128 application identifiers · split a gtin barcode payload into ai fields.
Decide before calling
Read the versioned contract and the supported scope below. Reuse gs1-element-string-parse@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use gs1-element-string-parse@1.0.0 for parse a gs1 element string. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
Supported
- parse a gs1 element string
- decode gs1-128 application identifiers
- split a gtin barcode payload into ai fields
- parse implied decimal net weight ai 310
- decode a gs1 batch lot and expiry date barcode
- read fnc1 separated application identifiers
Not supported
- the full GS1 Barcode Syntax Dictionary AI table (only 00, 01, 10, 11, 17, 21, 3100-3105, 37 are supported; any other well-formed AI throws unsupported_input)
- validating a single bare key without AI brackets (use gs1-key-validate)
- decoding a raw GS1 DataMatrix/QR binary payload (text must already be decoded to characters, including a literal GS U+001D for raw mode)
Behavior
- This tool supports a fixed 8-AI subset (data_version 'gs1-ai-subset-8-2026-10-01.1ea02f4e3b81'): 00 SSCC (fixed 18 digits, check_digit_valid set), 01 GTIN (fixed 14 digits, check_digit_valid set), 10 BATCH/LOT (variable 1-20 ASCII letters/digits), 11 PROD DATE (fixed 6-digit YYMMDD, date set), 17 USE BY OR EXPIRY (fixed 6-digit YYMMDD, date set), 21 SERIAL (variable 1-20 ASCII letters/digits), 3100-3105 NET WEIGHT (kg) (fixed 6 digits, decimal set), 37 COUNT OF ITEMS (variable 1-8 digits). Any other well-formed 2- or 4-digit AI throws unsupported_input; a malformed AI code throws invalid_input. value is always the exact captured field text, never reformatted.
- Implied-decimal rule (3100-3105 only): n is the AI's 4th character (0-5); decimal is value with '.' inserted so exactly n digits follow it (n=0: decimal equals value, no dot).
- Date rule (11 and 17 only): YY maps to 2000+YY when YY<=50, else 1900+YY; MM must be 01-12; DD='00' means the last day of that Gregorian month/year (leap years divisible by 4 except centuries not divisible by 400), otherwise DD must be a valid day of that month, else the whole request throws invalid_input. date is 'YYYY-MM-DD'.
- check_digit_valid (00 and 01 only) is the GS1 mod-10 check over value, its own last digit as the check digit.
- mode 'bracketed': text is one or more '(' + AI + ')' + VALUE groups, VALUE running to the next literal '(' or end of text; a GS anywhere throws invalid_input; a parenthesized code not in the supported subset throws unsupported_input if it is itself 2 or 4 digits, else invalid_input.
- mode 'raw': repeatedly read 2 digits as the AI (4 if they are '31' followed by a digit 0-5 forming 3100-3105); a fixed-length AI consumes exactly its declared length next; a variable-length AI reads to the next GS (U+001D) or end of text, consuming that GS as a separator (an immediately-following GS, empty value, or a GS anywhere else -- e.g. right after a fixed-length value, or two GS in a row -- throws invalid_input).
- Elements are returned in text order; more than 10 elements throws limit_exceeded. Pure string parsing, a pinned fixed AI table and integer/calendar arithmetic; no locale, clock, Intl, or randomness.
Input
text(string, required): min length 1; max length 200mode(one of "bracketed", "raw", required)
Output
elements(array of object, required): max items 10data_version(constant "gs1-ai-subset-8-2026-10-01.1ea02f4e3b81", required)
Limits
- max text bytes: 200
- max elements: 10
Example
Request input:
{
"text": "(01)04006381333931",
"mode": "bracketed"
}
Response:
{
"result": {
"elements": [
{
"ai": "01",
"title": "GTIN",
"value": "04006381333931",
"decimal": null,
"date": null,
"check_digit_valid": true
}
],
"data_version": "gs1-ai-subset-8-2026-10-01.1ea02f4e3b81"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "gs1-element-string-parse",
"version": "1.0.0",
"input": {
"text": "(01)04006381333931",
"mode": "bracketed"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/gs1-element-string-parse/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"text":"(01)04006381333931","mode":"bracketed"}'
The machine-readable contract is at /v1/tools/gs1-element-string-parse/versions/1.0.0.
CLI
node cli.mjs run gs1-element-string-parse 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Upu s10 validate: Validate a 13-char UPU S10 postal identifier's weighted mod-11 check digit, split service indicator and country.
- Checkdigit compute: Compute the check digit(s) for a payload under a named algorithm (Luhn, Verhoeff, Damm, ISO 7064, GS1, mod 10).
- Doi parse: Parse a DOI (bare, doi: or doi.org URL) into prefix, suffix, directory indicator, registrant code and canonical forms.
- Gs1 key validate: Validate a GTIN-8/12/13/14, GLN, SSCC or GSIN's GS1 mod-10 check digit and look up its 3-digit GS1 prefix meaning.
- Iccid validate: Validate a 19/20-digit ICCID's Luhn check digit, require the 89 major industry id, split issuer/account digits.
- Imei validate: Validate a 15-digit IMEI's Luhn check digit or accept a 16-digit IMEISV, and split the TAC from the serial.