^BX Data Matrix Bar Code

Generates a Data Matrix 2D barcode — compact, high-density encoding for small parts and pharmaceutical labels.

Supported in ZPL Preview

^BX generates a Data Matrix barcode, a 2D matrix code known for high data density in a very small footprint. Data Matrix is widely used in pharmaceutical (GS1 DataMatrix for drug tracing), aerospace (ATA 2000 spec), and electronics manufacturing for part marking.

Data Matrix can encode alphanumeric, ASCII, and binary data. A 22×22 symbol can encode up to 30 characters; a 144×144 symbol can encode up to 3116 numeric digits or 2335 text characters. This density makes it suitable for very small labels (down to 1mm² with industrial marking).

The dimension parameter (h) sets the module size in dots — unlike ^BQ (QR Code) which uses a separate magnification factor, ^BX uses h as both height of each module and implicitly controls the overall symbol size in combination with symbol size (s and c parameters). Setting h to 3 at 203 DPI gives 3-dot (≈15 mil) modules.

Data Matrix uses ECC 200 error correction by default, which provides up to 30% error recovery. This means even a significantly damaged symbol (scratched, dirty) can still be read if the damage doesn't exceed the ECC threshold.

For GS1 DataMatrix (pharmaceutical serialization like DSCSA, SNDC), the data must include the appropriate Application Identifiers (01, 17, 10, 21) with proper FNC1 encoding.

Syntax

^BXo,h,s,c,r,f,g

Parameters

ParameterTypeDefaultDescription
oN | R | I | BNOrientation: N = normal, R = 90°, I = 180°, B = 270°.
hintegeroptionalHeight of each individual module (cell) in dots.
sinteger200Symbol size: 0 = auto-size (smallest that fits data), or a specific Data Matrix size code (e.g., 200 = 10×10 up to 144×144).
cinteger200Columns per region. Used for rectangular Data Matrix symbols.
rinteger0Rows per region. 0 = auto.
fstring~Format ID — tilde character in most implementations.
ginteger1Aspect ratio: 1 = square, 2 = rectangular.

Examples

Auto-sized Data Matrix encoding a product code

Try in Viewer
^XA
^FO50,50^BXN,3,200^FDPROD-ABC-001234^FS
^XZ

Data Matrix with larger modules for easy scanning

Try in Viewer
^XA
^FO50,50^BXN,5,200^FDINV-2026-98765^FS
^XZ

Common Mistakes

  • !Setting module size (h) too small — at 1-2 dots at 203 DPI the symbol is too small for most industrial scanners.
  • !Using Data Matrix for consumer retail labels — QR Code or EAN/UPC are expected by retail POS systems.
  • !Forgetting FNC1 encoding for GS1 DataMatrix — pharmaceutical/GS1 use requires specific Application Identifier formatting.
^BX Data Matrix Bar Code — ZPL Command Reference | Prynta Co | Prynta Co