Skip to content

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.

AIDescriptionExample
01GTIN (14 digits)01095011010209
10Batch/Lot Number10ABC123
17Expiration Date (YYMMDD)17261231
21Serial Number21XYZ789

Input Format

Use parentheses to wrap AIs in your input. xBarcode automatically:

  1. Strips the parentheses
  2. Inserts FNC1 as the first character (GS1 mode indicator)
  3. Inserts Group Separator (GS, ASCII 29) after variable-length fields

Example Input:

(01)09501101020917(17)261231(10)ABC123

Encoded Data:

[FNC1]0109501101020917172612311[GS]0ABC123

API Examples

GS1 QR Code

GET /gs1_qr/(01)09501101020917(17)261231(10)ABC123

GS1 DataMatrix

GET /gs1_datamatrix/(01)09501101020917(21)SERIAL001

Variable-Length vs Fixed-Length AIs

AI TypeGroup SeparatorExamples
Fixed-lengthNot required01 (14 digits), 17 (6 digits)
Variable-lengthRequired after10, 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