GS1 Barcode Guide
xBarcode provides native support for GS1-compliant barcodes, automatically handling FNC1 characters and group separators according to international standards.
Overview
GS1 is an international standard for encoding product and logistics data in barcodes. xBarcode supports GS1 mode for:
- GS1 QR Code —
/gs1_qr/{content} - GS1 DataMatrix —
/gs1_datamatrix/{content}
Application Identifiers (AIs)
GS1 data is structured using Application Identifiers (AIs) that define the meaning of subsequent data fields.
| AI | Description | Example |
|---|---|---|
01 | GTIN (14 digits) | 01095011010209 |
10 | Batch/Lot Number | 10ABC123 |
17 | Expiration Date (YYMMDD) | 17261231 |
21 | Serial Number | 21XYZ789 |
Input Format
Use parentheses to wrap AIs in your input. xBarcode automatically:
- Strips the parentheses
- Inserts FNC1 as the first character (GS1 mode indicator)
- Inserts Group Separator (GS, ASCII 29) after variable-length fields
Example Input:
(01)09501101020917(17)261231(10)ABC123Encoded Data:
[FNC1]0109501101020917172612311[GS]0ABC123API Examples
GS1 QR Code
GET /gs1_qr/(01)09501101020917(17)261231(10)ABC123GS1 DataMatrix
GET /gs1_datamatrix/(01)09501101020917(21)SERIAL001Variable-Length vs Fixed-Length AIs
| AI Type | Group Separator | Examples |
|---|---|---|
| Fixed-length | Not required | 01 (14 digits), 17 (6 digits) |
| Variable-length | Required after | 10, 21, 30, etc. |
xBarcode handles this automatically—simply provide properly formatted AI strings.
Common Use Cases
Product Packaging
GET /gs1_datamatrix/(01)00012345678905(17)261231(10)LOT001- GTIN:
00012345678905 - Expiry: December 31, 2026
- Lot:
LOT001
Serialized Items
GET /gs1_qr/(01)00012345678905(21)UNIQUE-SERIAL-123- GTIN:
00012345678905 - Serial:
UNIQUE-SERIAL-123
Error Handling
Invalid GS1 input (malformed AIs, incorrect lengths) returns:
400 Bad Request
Invalid GS1 format: AI (01) requires 14 digits