Every traceability system eventually meets a physical label, and that is where a lot of otherwise sound designs come apart. The internal data model can be immaculate, with lot identity on every transaction and a complete genealogy, and yet the label going out of the door carries a batch code in a proprietary format that only your own scanners understand. The point of GS1 is to remove that ambiguity: it provides a numbered identifier for each kind of data, so that a scanner anywhere in the world can read a string of digits and know which part is the product, which part is the batch and which part is the expiry date.
The message up front: you need four identifiers for batch-level traceability, AI (01) for the product, AI (10) for the batch or lot, AI (17) for expiry and AI (21) for a serial where you have one. The technical detail that causes most real-world failures is that AI (10) and AI (21) are variable length, so they must either be placed last in the data string or be followed by a separator character. Get that wrong and the scanner silently reads your expiry date as part of your batch code. The label will look perfect and the data will be wrong.
1. What GS1 actually gives you
GS1 is the organisation behind the barcodes on retail products worldwide, and its General Specifications define how data is encoded in them. The mechanism relevant here is the Application Identifier, usually written AI: a two-to-four digit prefix that declares what the following data means.
The value of this is interoperability without negotiation. If you print a batch number with no identifier, a receiving warehouse has to be told, by email or by integration spec, that characters 15 to 24 of your label are the batch. If you print it behind AI (10), any compliant scanner in any company knows it is a batch or lot number because the standard says so. That is the whole proposition, and it is why standards-based labelling is worth the configuration effort even for businesses with only a handful of trading partners.
All the identifiers below are verifiable directly against GS1's own Application Identifier reference , which publishes the official description, format and length rules for each. I would recommend checking against that source rather than any secondary summary, including this article, because the formats are occasionally revised.
2. The identifiers you actually need
For batch and lot traceability on a manufactured or distributed product, the working set is small. Six identifiers cover almost everything, and the format notation reads as follows: N is a numeric character, X is any character from the permitted character set, and .. indicates a variable length up to the number shown.
| AI | Official description | Format | Length | What it is for |
|---|---|---|---|---|
| (01) | Global Trade Item Number (GTIN) | N2+N14 | Fixed, 14 | Which product this is. The anchor of every GS1 data string. |
| (10) | Batch or lot number | N2+X..20 | Variable, up to 20 | Carries whichever batch or lot identity you are passing on. One barcode field for both terms. |
| (11) | Production date (YYMMDD) | N2+N6 | Fixed, 6 | When it was made. Useful where shelf life is calculated downstream. |
| (17) | Expiration date (YYMMDD) | N2+N6 | Fixed, 6 | The use-by or expiry limit. GS1 titles this field USE BY or EXPIRY. |
| (21) | Serial number | N2+X..20 | Variable, up to 20 | One specific unit, where you serialise. |
| (00) | Serial Shipping Container Code (SSCC) | N2+N18 | Fixed, 18 | Identifies a logistic unit, typically a pallet, not the product on it. |
Three things in that table are worth drawing out, because each one settles a question that comes up repeatedly.
AI (10) is described as "Batch or lot number". One field, both words, so at the labelling layer there is no batch-versus-lot distinction to encode. The implication is about the label, not about your database: a barcode carries one identity, so you must decide which one you are passing on. That does not mean an ERP should hold only one. A supplier batch reference, an internal receipt lot and a production batch are separate identities with separate scopes, and a working system holds all of them linked by parentage while printing whichever the trading partner needs. The fuller argument is in batch vs lot vs serial number.
AI (17) is titled USE BY or EXPIRY, which is a labelling decision with regulatory consequences attached, because under EU rules a use-by date and a best-before date mean materially different things and are not interchangeable. The barcode field does not distinguish them, so the human-readable text on the pack has to. That is treated in shelf life vs expiry date vs best before date.
Dates are YYMMDD, six digits, with no century. A two-digit year is a deliberate space-saving choice and it means the encoded date is ambiguous across a hundred-year span. In practice that is resolved by a sliding window convention, not by the barcode. Anything with a genuinely long life needs the date held in your system rather than inferred from the label.
3. Building the data string
A GS1 data string is just identifiers and their values concatenated. A sauce case, GTIN 05012345678900, batch TP0871, expiry 31 March 2027:
(01) 05012345678900 (17) 270331 (10) TP0871
Encoded data string:
0105012345678900 17270331 10TP0871
Reading it back:
01 → next 14 fixed → 05012345678900 (product)
17 → next 6 fixed → 270331 (expiry 2027-03-31)
10 → variable → TP0871 (batch, runs to the end)
The parentheses are a human-readable convention printed under the bars. They are not part of the encoded data. A common integration error is to store the brackets in a database field, after which the value no longer matches anything scanned.
The order worked above is deliberate. The two fixed-length fields come first and the variable-length batch comes last, which means the scanner can consume each fixed field by counting characters and then take everything remaining as the batch. GS1 does not require AIs to appear in any particular sequence, so this is not a rule, but it is the arrangement that avoids the problem in the next section.
4. The variable-length separator, which is where labels go wrong
This is the single most important technical detail in GS1 batch labelling, and it is the one most often missed by teams building labels for the first time.
A fixed-length field is self-terminating: a scanner reading AI (17) knows to take exactly six characters. A variable-length field is not. AI (10) can be anything from one to twenty characters, so a scanner reading it has no way to know where it ends unless you tell it. GS1's own identifier data marks both AI (10) and AI (21) with a separator-required flag for exactly this reason.
There are two valid ways to resolve it, and one of them is much easier:
- Put the variable-length field last. If nothing follows it, "runs to the end of the data" is unambiguous and no separator is needed. For most labels carrying one batch number this is the simplest correct answer, and it is why the example above is ordered as it is.
- Terminate it with the separator character. Where a variable-length field must be followed by another field, it is terminated with the function character known as FNC1, which acts as a group separator. In the data stream this is represented by the ASCII group separator, decimal 29.
What happens when it is omitted is the reason this matters so much:
0105012345678900 10TP0871 17270331
What the scanner does:
01 → 05012345678900 correct
10 → TP087117270331 batch swallows the expiry field
17 → never read, there is nothing left
Result: batch code wrong, expiry date MISSING.
The printed label looks completely normal.
Why this one is dangerous rather than merely wrong
A missing separator does not produce a scan failure. It produces a successful scan of corrupted data. The barcode verifies, the print quality passes, the human-readable text under the bars is correct, and the receiving system silently records a malformed batch and no expiry date. Nothing surfaces until someone tries to run a trace or a FEFO rotation and finds the dates are absent. Test by scanning and inspecting the decoded fields, never by looking at the label.
5. Choosing the symbology
The identifiers are independent of the barcode shape that carries them. Three carriers do almost all the work in batch labelling:
| Carrier | Shape | Typical use | Practical constraint |
|---|---|---|---|
| GS1-128 | Linear, 1D | Cases, pallets, logistics labels | Gets physically wide as you add fields. Needs a flat surface and a wide label. |
| GS1 DataMatrix | 2D square | Small items, pharmaceutical and medical device packs | Needs an imaging scanner. Laser scanners cannot read it at all. |
| GS1 DataBar | Linear, 1D | Retail point of sale on fresh and variable-measure items | Point-of-sale equipment support varies by market and must be confirmed. |
The decision is usually made for you by two things: the physical space on the pack and what your trading partners can scan. Space pushes towards DataMatrix, because a 2D symbol holds far more data in far less area. Trading partner capability often pushes back towards GS1-128, because a distribution centre with laser scanners cannot read a 2D symbol no matter how correct it is.
I would resolve that by asking, before the label is designed, what the receiving party actually scans with. It is a question with a factual answer, it takes one email, and discovering it afterwards means reprinting. Where the answer is mixed, carrying both a GS1-128 and a DataMatrix on the same label is legitimate and common.
6. Implementing it without creating a second source of truth
The integration pattern that works, and the one failure mode to avoid:
Label data should be derived at print time from the lot record, never typed into a label template and never stored separately. The lot record already holds the item, the lot code and the expiry date. The label is a rendering of those fields. The moment a label system holds its own copy of an expiry date, you have two sources of truth and they will diverge, usually when a lot is re-dated after a quality decision and the label system is not told.
item_id → item.gtin → AI (01)
lot_code → AI (10)
expiry_date → YYMMDD → AI (17)
↓
build data string, apply separators
↓
render symbol + human readable text
Two constraints worth building in from the start. First, validate the lot code against the permitted character set before it can be saved, not at print time. A lot code containing a character the encoding does not permit, or exceeding twenty characters, is a data problem that should be rejected at entry rather than discovered by a label printer. Second, the GTIN belongs on the item master, allocated from your own GS1 company prefix. A GTIN invented locally will collide with somebody else's product, which is a harder problem to unwind than it sounds.
On the receiving side, parsing is the mirror image: read the AI, look up whether it is fixed or variable length, take the right number of characters or read to the separator, and map the value onto your own lot fields. The parser is the component that most repays being written once, properly, and shared. Writing a new one per interface is how a business ends up with three subtly different interpretations of the same label. This sits alongside the general warehouse scanning picture in barcode integration with ERP.
7. The mistakes worth knowing in advance
- Omitting the separator after a variable-length field. The defect described in section 4. Corrupts data while the label looks correct.
- Storing the human-readable parentheses as data.
(10)TP0871stored in a batch field will never match the scanned valueTP0871. - Inventing a GTIN. GTINs are allocated from a licensed company prefix. A made-up one is somebody else's product identifier.
- Printing a 2D symbol a partner cannot scan. Confirm the receiving capability before designing the label, not after the first delivery is rejected.
- Using AI (17) while the pack text says best before. The barcode field does not distinguish safety dates from quality dates. The human-readable text has to be right for the jurisdiction, independently of the encoding.
- Letting the label system own the expiry date. Two sources of truth, guaranteed to diverge on a re-date.
- Treating a verified print as a verified label. Print verification checks bar geometry and contrast. It does not check that your AI structure is semantically correct. Those are different tests and you need both.
- Assuming the dash in a lot code survives. Permitted character sets are specific. Validate at entry.
What standards-based labelling does not give you
A correct GS1 label makes your batch identity readable by anyone. It does not create traceability. If the lot is captured at receipt and then stock moves internally without carrying it, or consumption is derived from the bill of materials rather than scanned at the line, the label is a well-formed identifier for a chain that has gaps in it. Labelling is the interoperability layer, not the traceability layer, and getting it right is the easier half of the job.
The idea to walk away with
Four identifiers carry batch-level traceability: AI (01) for the product, AI (10) for the batch or lot, AI (17) for expiry, AI (21) for a serial. Two of those, (10) and (21), are variable length and therefore need either a terminating separator or the last position in the data string. Put the variable-length field last wherever you can, because the arrangement that needs no separator is the arrangement that cannot be got wrong.
Derive label content from the lot record at print time, validate lot codes against the permitted character set at entry, and verify by decoding a real scan rather than by inspecting the printed label. The failure mode here is silent, and the only test that catches it is reading the fields a scanner actually produced.
Final thoughts
GS1 labelling is unusually tractable work: the rules are published, the identifiers are unambiguous, and a correct implementation is verifiable in an afternoon by scanning a sample and comparing decoded fields against the lot record. That is a rare combination, and it is a good reason to get this layer right early rather than treating it as the last step before despatch.
The harder half of traceability is upstream of the label, in whether lot identity survives every internal transaction. If you have not tested that, start with lot traceability from raw materials to finished goods, and then with the two query directions in forward and backward traceability.
Designing batch labels or a scanning interface?
Independent advisory on GS1 data structures, label integration with ERP, barcode parsing and the lot data model behind both. 22+ years across enterprise systems implementation. No vendor margins.
Book a conversationRelated reading: Barcode integration with ERP, 1D vs 2D barcodes, QR codes vs barcodes, Barcode-based inventory management, Serial number tracking.
Muhammad Abbas
CMMS / CAFM Manager & Independent Advisor · 22+ years across enterprise CMMS, EAM, CAFM and ERP implementations in utilities, oil and gas, manufacturing, government and facility operations.
Work with me