{"id":"gs1-element-string-parse","version":"1.0.0","description":"Parse a bracketed or FNC1-separated GS1 element string into typed AI fields: implied decimals, dates and check digits.","supported_operations":["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"],"unsupported_operations":["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)"],"semantics":["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."],"limits":{"max_text_bytes":200,"max_elements":10},"pricing":{"status":"unpriced","charge_usd":null},"input_schema":{"type":"object","additionalProperties":false,"required":["text","mode"],"properties":{"text":{"type":"string","minLength":1,"maxLength":200},"mode":{"type":"string","enum":["bracketed","raw"]}}},"output_schema":{"type":"object","additionalProperties":false,"required":["elements","data_version"],"properties":{"elements":{"type":"array","maxItems":10,"items":{"type":"object","additionalProperties":false,"required":["ai","title","value","decimal","date","check_digit_valid"],"properties":{"ai":{"type":"string","pattern":"^([0-9]{2}|310[0-5])$"},"title":{"type":"string","enum":["SSCC","GTIN","BATCH/LOT","PROD DATE","USE BY OR EXPIRY","SERIAL","NET WEIGHT (kg)","COUNT OF ITEMS"]},"value":{"type":"string","minLength":1,"maxLength":20},"decimal":{"type":["string","null"]},"date":{"type":["string","null"],"pattern":"^[0-9]{4}-[0-9]{2}-[0-9]{2}$"},"check_digit_valid":{"type":["boolean","null"]}}}},"data_version":{"type":"string","const":"gs1-ai-subset-8-2026-10-01.1ea02f4e3b81"}}},"examples":[{"input":{"text":"(01)04006381333931","mode":"bracketed"},"output":{"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"}},{"input":{"text":"(11)280200","mode":"bracketed"},"output":{"elements":[{"ai":"11","title":"PROD DATE","value":"280200","decimal":null,"date":"2028-02-29","check_digit_valid":null}],"data_version":"gs1-ai-subset-8-2026-10-01.1ea02f4e3b81"}}],"execute_url":"/v1/tools/gs1-element-string-parse/versions/1.0.0/execute"}