Skip to content
Utilerio

What GS1 Barcodes Actually Encode

The long digit string under a shipping label isn't random — every two- or three-digit number in parentheses is an Application Identifier pointing at a specific field, from product id to expiration date.

· 2 min read

Scan the barcode on a shipping carton or a retail product and you get something like 01123456789012311725123110ABC123 — to the eye, an arbitrary run of digits. It isn't. This is the GS1 standard's way of concatenating fields end to end, each one introduced by an Application Identifier (AI). (01) marks a GTIN, (17) an expiration date, (10) a batch/lot number; the scanner never sees the parentheses, but the system reading the result knows exactly where to split the string because each AI has either a fixed length or a defined terminator.

Fixed-length versus variable-length

GS1 AIs split into two categories, and that split is the whole basis of correct parsing:

  • Fixed-length fields — (01) GTIN is always exactly 14 digits, (17) expiration date is always 6 digits in YYMMDD. A parser doesn't need to scan ahead for these; it just reads the known width.
  • Variable-length fields — (10) batch number or (21) serial number run either to the end of the string or until a Group Separator (ASCII 29, an invisible control character) shows up. The parser has to actively look for that separator before it can know where the next AI starts.

That mix makes a hand-rolled regex misleadingly fragile — guessing wrong about where a variable-length field ends shifts everything after it, misreading a completely different field as the wrong AI.

Why it looks right most of the time and wrong occasionally

A hand-written parser for the common AIs (GTIN, expiration date, batch number) works on most real labels because those three are fixed-length or predictable in shape. The trouble shows up with the less common but equally standard-defined AIs — a production date, a customer-specific batch field, or a field whose correctness depends on whether a Group Separator is actually present. GS1 Parser parses against the full standard AI table, labels every field with its human-readable name (not just its code), and converts date fields from YYMMDD into a readable date — so you see 2025-12-31 instead of 251231.

Reading and generating share the same standard

Decoding a scanned barcode and generating one depend on the exact same AI table — Barcode Reader gives you the raw scanned string, Barcode Generator builds an actual barcode image from a string formatted with the right AIs. Running GS1 Parser between the two is a way to confirm the label you're about to produce actually carries the fields you think it encodes, before you generate it. If the label itself is the wrong physical size — a printer template built for a different carrier — Shipping Label Resizer adjusts the dimensions without touching the barcode's content at all.