gs1
v0.3.0GS1 element strings, DataMatrix, eight keys, ITF-14 print specs and price-embedded in-store codes.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
build_gs1_element_string Build a GS1-128 element string from application identifiers
The inverse of parse_gs1_element_string: turn AI/value pairs into the string a barcode actually carries. THREE FORMS come back and only one of them is the data: `hri` is the human-readable form with brackets — never encode those; `data` is the real payload where FNC1 is the ASCII group separator (U+001D); `visible` is the same payload with FNC1 shown as <GS> so it survives being pasted into a chat or a ticket. Separator rule, both halves: a variable-length element is closed by FNC1 UNLESS it is the last element — omitting it runs two fields together, and adding a trailing one makes the sym…
| Parameter | Type | Description |
|---|---|---|
elements | array | Structured elements, e.g. [{ai:"01",value:"04006381333931"},{ai:"10",value:"LOT-A"}]. |
keepOrder | boolean | Encode in the given order instead of moving predefined-length AIs to the front. |
text | string | Free-form input instead of `elements`: bracketed HRI, one "AI value" per line, or a scanned string. |
generate_gs1_datamatrix Generate a GS1 DataMatrix (ECC200) from application identifiers
Build a GS1 DataMatrix symbol and return it as SVG plus the module matrix. WHAT MAKES IT A *GS1* DataMatrix: FNC1 in the first position (codeword 232). Without it the symbol is a plain DataMatrix carrying digits and no scanner has any reason to read 0104006381333931 as a GTIN; with it the scanner emits the ]d2 symbology identifier and downstream systems split the data into AIs. This tool always sets it. The element string is validated BEFORE anything is drawn (unknown AI, wrong length, bad check digit, invalid date, character set) and no symbol is returned when a check fails — a symbol that…
| Parameter | Type | Description |
|---|---|---|
elements | array | Structured AI/value pairs, e.g. [{ai:"01",value:"04006381333931"}]. |
moduleSize | number | SVG module size in px (default 8). Cosmetic only — it does not change the symbol. |
text | string | Free-form alternative to `elements`: "(01)…(17)…", or one "AI value" per line. |
xDimensionMm | number | Module size in millimetres for the printed-size calculation (default 0.5). |
validate_gs1_extended_key Validate GRAI, GIAI, GSRN, GDTI, GINC, GSIN, GCN or GMN
Validate the eight GS1 keys beyond SSCC and GLN (those two live in validate_gs1_key). The key type must be given: several of these share a length, so guessing would be wrong more often than right. Formats come from the GS1 Barcode Syntax Dictionary, GS1's own machine-readable source: GRAI = a literal 0 plus 13 digits with a check digit plus an optional 16-character serial; GIAI = up to 30 characters, NO check digit; GSRN (8017 provider / 8018 recipient) = 18 digits with a check digit; GDTI = 13 digits with a check digit plus an optional 17-character serial; GINC = up to 30 characters, NO check…
| Parameter | Type | Description |
|---|---|---|
key * | string | Which key this value is meant to be. Required — several of these share a length. |
value * | string | The key, with or without its AI prefix such as "(8003)". |
list_gs1_keys List the GS1 identification keys and their syntax
Return the GS1 keys this server can validate, each with the application identifiers that carry it, what it identifies, and its syntax as written in the GS1 Barcode Syntax Dictionary (for example "N1,zero N13,csum [X..16]" for GRAI). Useful before validating: it tells you which key a given AI belongs to, which keys carry a check digit, and which two (GIAI, GINC) carry none at all. Returns { keys[{key, ais, name, identifies, syntax, hasCheckDigit, hasCheckPair, numericLength?, maxLength?}] }.
check_itf14_spec Check an ITF-14 case code print specification and compute its printed size
Judge the PRINT SPECIFICATION of an ITF-14 carton barcode against the GS1 General Specifications (Release 26.0), and compute how big it will actually be. This is the layer the barcode generators skip: they draw the symbol, but a case code is rejected at goods-in for its dimensions far more often than for its number. THE BEARER BAR RULE DEPENDS ON THE PRESS, and getting this backwards is the main way a compliant label gets called non-conformant: a plate-based process needs a constant 4.83 mm bearer bar completely surrounding the symbol including its quiet zones (it equalises plate pressure); a…
| Parameter | Type | Description |
|---|---|---|
bearerBar * | string | Bearer bar layout: fully surrounding, top and bottom only, or absent. |
printMethod * | string | "plate" for presses needing printing plates (flexo direct on carton), "plateless" for thermal, laser or offset labels. Decides which bearer bar rule applies. |
xDimension * | number | Width of a narrow element (X) in millimetres. Required — everything else scales off it. |
barHeight | number | Bar height in millimetres, excluding human readable digits and bearer bars. Defaults to the 31.75 mm minimum. |
bearerBarThickness | number | Bearer bar thickness in millimetres. Omit to skip the thickness rules rather than have them guessed. |
bearerToHriGap | number | Gap between the bearer bar and the human readable digits, in millimetres. Minimum 1.02. |
directOnCorrugate | boolean | True when the symbol is printed straight onto corrugate rather than onto an applied label. |
gtin | string | The GTIN-14 the symbol carries; its check digit is verified when given. |
quietZone | number | Quiet zone each side in millimetres. Defaults to 10X. |
ratio | number | Wide-to-narrow ratio, 2.25 to 3.0. Defaults to the 2.5 target. |
decode_variable_measure_code Decode a variable-measure (price- or weight-embedded) in-store barcode
Decode an RCN-12 / RCN-13 — the 02 or 20–29 number a scale prints on a deli, produce or butcher label — into item reference, embedded price or weight, and the two check digits it carries. WHY THIS IS NOT A GTIN VALIDATOR: prefixes 02 and 20–29 are Restricted Circulation Numbers whose layout is set by each GS1 member organisation, so the same 13 digits mean different things in different countries (22 is a five-digit AUD price with a verifier in Australia and an integer SEK price without one in Sweden). The tool decodes under every documented scheme whose prefix matches and lists them si…
| Parameter | Type | Description |
|---|---|---|
scheme | string | Pin a national scheme instead of showing every scheme that fits the prefix. |
value | string | One 13-digit EAN-13 (02…/2X…) or 12-digit UPC-A (2…) number; spaces and hyphens are tolerated. |
values | array | Batch alternative to `value`: one number per element. |
build_variable_measure_code Build a variable-measure barcode number with its price check digit
The inverse of decode_variable_measure_code: from a national scheme, an item reference and a price or weight, produce the complete 13-digit number (and the 12-digit UPC-A form for prefix 02) with BOTH check digits computed — the price/measure verifier from GS1 General Specifications §7.9.3 (four-digit field: factors 2−,2−,3,5−, sum × 3, units digit) or §7.9.4 (five-digit field: factors 5+,2−,5−,5+,2−, complement to ten, reverse lookup in the 5− table), then the ordinary mod-10 check digit over the twelve. The standard's own worked examples (2875 → 9, 14685 → 6) are regre…
| Parameter | Type | Description |
|---|---|---|
itemReference * | string | Item reference digits, exactly the length the scheme uses (5 for us/uk-branded/gr, 4 for uk-instore/au/de, 6 for se). |
scheme * | string | National scheme to encode under. |
value * | number | string | Price or measure in the scheme's unit, e.g. 28.75 or "1.234". |
prefix | string | Two-digit GS1 prefix, e.g. "23"; required when the scheme has several with different meanings. |