GS1-128 and GS1-DataMatrix Barcodes

Here are some examples how to encode GS1 product specifications and traceability information in linear and 2D barcodes.

Only text strings and proper AI formatting examples are shown. If you need step-by-step examples for some programming environments, see in the related tutorials.

With StrokeScribe Barcode Generator, you can quickly create GS1-128 and GS1-DATAMATRIX barcodes, directly in Microsoft Office and LibreOffice products or .NET apps. This powerful tool is perfect for generating accurate and scannable GS1 barcodes for inventory management, shipping labels, and retail applications.

Generate high-quality GS1-128 and GS1-DATAMATRIX barcodes directly in your apps with ease. Whether for product tracking, compliance, or logistics, StrokeScribe allows you to produce reliable GS1 barcodes that fit perfectly into your processes, saving time and increasing productivity.

GS1-128 Barcode Basics

GS1-128 (formerly EAN-128) barcode is a simple linear barcode based on CODE 128 symbology. These barcodes are readable by all types of barcode scanners and can be used to store a relatively small amount of data.

GS1-128 barcode

To distinguish a valid GS1-128 barcode from other CODE 128 symbols, a Function Command 1 must be placed into the barcode before the data payload. The FNC1 is an internal CODE 128 command and cannot be directly encoded in the user-supplied data. The StrokeScribe ActiveX will automatically insert FNC1 into a barcode if the Alphabet property is set to EAN128.

GS1-128 barcodes have the following physical limitations:

GS1-DataMatrix Barcode Basics

GS1-DataMatrix barcode is based on high capacity 2D DataMatrix symbology. This barcode type is able to store a huge amount of data, but it cannot be read by cheap laser/CCD barcode scanners.

GS1-DataMatrix

To distinguish a valid GS1-DataMatrix barcode from other DataMatrix symbols, a FNC1 command must be placed into the barcode before the data payload. The FNC1 is an internal barcode command and cannot be directly encoded in the user-supplied data. The StrokeScribe ActiveX will automatically insert FNC1 into a barcode if the Alphabet property is set to GS1DATAMATRIX.

GS1-DataMatrix barcodes have the following physical limitations:

Do not try to simulate barcode scanner escape sequences like ]C1 and ]d2 by storing them in the user-supplied data in plain CODE-128 or DataMatrix barcodes. The escape sequences are automatically generated by scanner if a correct barcode type is detected and only if the scanner is configured to output escape sequences. Simulation will not make your barcode correct in any way.

GS1 Data Encoding Examples

The product specification and traceability information is stored in a concatenated list of fields where each field is described by an Application Identifier (AI).

For example, AI 310Y represents the Product Net Weight in Kilograms and Y is a decimal point position indicator. To encode a Net Weight of 12.3Kg, we must put the AI=310, Y=1 and 000123 together: 3101000123.

The full list of supported Application Identifiers is available at the AI compatibility list and here are the most popular AIs with encoding examples:

AI Description Data Structure Example
10 Batch Number 1-20 Alphanumerics 10ABCD1234
11 Production Date 6 Digits: YYMMDD
  • May, 03, 2012 => 11120503
  • Dec, 31, 1999 => 11991231
17 Expiration Date 6 Digits: YYMMDD May 17th, 2001 => 17010517
310Y Product Net Weight in Kilograms 6 Digits 5.3 Kg => 3101000053
311Y Product Length (Meters) 6 Digits 5.3 meters => 3111000053
312Y Product Width (Meters) 6 Digits
  • 5.43 meters => 3122000543
  • 5.432 meters => 3123005432
313Y Product Depth (Meters) 6 Digits 54.3 meters => 3131000543
315Y Product Volume (Liters) 6 Digits 54.32 L => 3152005432
321Y
324Y
327Y
Product Length (Inch)
Product Width/Diameter (Inch)
Product Depth/Thickness/Height (Inch)
6 Digits
  • 54.32 in. length => 3212005432
  • 54.32 in. height => 3272005432
330Y Container Gross Weight, Kg 6 Digits
  • 345678 Kg => 3300345678
  • 34567.8 Kg => 3301345678
  • 3456.78 Kg => 3302345678
  • 345.678 Kg => 3303345678
  • 34.5678 Kg => 3304345678
  • 3.45678 Kg => 3305345678
331Y
332Y
333Y
Container Length (Meters)
Container Width/Diameter (Meters)
Container Depth/Thickness (Meters)
6 Digits A width of 12.3456 m. => 3324123456
335Y Container Gross Volume, Liters 6 Digits 4.56 L => 3352000456

How to Build a Real-World GS1 Barcode

Let's build a GS1 string that contains a Gross Weight, a Product Volume and Expiration Date.

A GS1-128 barcode with Gross Weight and Product Volume

A Container Gross Weight of 567.47 kilograms is encoded as:

A Product Volume of 12.345 liters is encoded as:

An Expiration Date of 01/Mar/2015 is encoded as:

Concatenate these 3 strings into one string in any order and send it to the barcode encoder:

Attention! Do not put additional parentheses into AIs. Parentheses appear below GS1 barcodes only for better human readability and generated automatically.

A bit of programming. This function may help VBA developers to properly format values with the decimal point position indicator for the Y-based AIs.

Pass a string like "5.678" to the function and it will return a zero-padded string "3005678" that also contains the Y-value.

Public Function Y6N(txt) p = InStr(txt, ".") If p > 0 Then p = Len(txt) - p txt = Replace(txt, ".", "") v = Format$(txt, "000000") y = Format$(p, "0") Y6N = y + v End Function

Batch Number / Serial Number / Internal Company Codes and Other Variable Length AIs

A Batch Number (AI 10) or a Serial Number (AI 21), for example, may contain up to 20 alphanumeric characters. To tell the receiving party where to start looking for the next AI, the FNC1 separator character must be placed at the end of the variable length field.

Because the FNC1-FNC3 are the internal barcode commands and cannot be directly encoded in the user-supplied data, the ActiveX translates ASCII GS (decimal code 29) control characters to FNC1. The easiest way to insert ASCII GS in a VB/VBA application is to use the Chr$(29) function call.

Let's build a large GS1 barcode that contains:

A multi-AI GS1-128 barcode

The Batch number and the Customer P.O. Number are variable-length AIs.

The sequenceWhat is encoded
10ABC123<GS>AI 10, the serial number = ABC123, then ASCII GS
3151000035AI 315, Y=1, the volume = 3.5 liters
3300000001AI 330, Y=0, the gross weight = 1Kg
11151231AI 11, the production date = 31-Feb-2015
17161231AI 17, the expiration date = 31-Feb-2016
40012345678AI 400, the P.O. number = 12345678

Always consult with the GS1 General Specifications for proper AI formatting!

To separate the variable length AI 10 from the others, we inserted ASCII GS (decimal code 29) after the field. There is no need to append ASCII GS if a variable length AI is placed at the end of a barcode.

Here is how to concatenate all sequences and GS control characters into one string in VB or VBA (Excel, Access).

Dim s As String s = "10ABC123" & Chr(29) & "3151000035" & "3300000001" & "11151231" & "17161231" & "40012345678"