Skip to main content
Data Matrix is a compact square or rectangular 2D barcode. It holds more in less space than a QR Code, which is why it’s the usual choice for marking small parts and medicine packs.

Decode one

Scan or paste a barcode and see every part of it.

Make one

Generate a valid barcode from fields.

Where you’ll see it

  • Medicine packs and medical devices, as GS1 DataMatrix carrying a GTIN, expiry date, batch and serial number.
  • Electronic components and machined parts, often marked straight onto the part by laser or dot peen.
  • Postage, on some postal services’ printed stamps and labels.
  • Products, alongside or in place of a UPC or EAN, as retailers adopt 2D barcodes. See Sunrise 2027.

Anatomy

This example is a GS1 DataMatrix carrying a GTIN, an expiry date and a batch.

The finder pattern and clock track

Two solid edges form an L, which tells a scanner where the code is and which way up it is. The other two edges alternate dark and light, setting out the grid of modules. In larger sizes the code is split into regions, each with its own L and clock track, so you’ll see lines through the middle.

Sizes

Square sizes run from 10×10 to 144×144 modules, and rectangular sizes from 8×18 to 16×48. An encoder picks the smallest size that fits the data. The largest square holds up to 3,116 digits or 2,335 letters and digits.

Quiet zone

Data Matrix needs a light margin at least 1 module wide on every side. More is safer.

Error correction

Data Matrix uses Reed–Solomon error correction, and the amount is fixed by the size: you don’t choose a level. Small codes spend about as many codewords on error correction as on data, so they’re very robust for their size. To make a Data Matrix tougher, print it with larger modules and keep its quiet zone clear. See How much error correction should I use?
  • GS1 DataMatrix: a Data Matrix that starts with the GS1 special character FNC1 and carries GS1 element strings. It’s what’s on medicine packs. Some scanners report it with ]d2 in front of the data.
  • ECC 000 to ECC 140: older forms of Data Matrix that are obsolete. Everything current is ECC 200, shown here.
  • QR Code: larger for the same data, but more familiar to phone users.
  • GS1-128: the same GS1 data in a linear barcode.

Gotchas

  • Fields run together. As with GS1-128, the parentheses in the printed text aren’t in the data. See parentheses missing from the scan.
  • Separators in the data. A variable-length field followed by another field ends with the GS character. See invisible characters.
  • Marks on metal and plastic. Codes marked straight onto parts can be low contrast or shiny, which phone cameras find much harder than print.

Scanning it in your app

A Data Matrix that carries a GTIN, as GS1 DataMatrix or a GS1 Digital Link, also counts as a product barcode in the Retail product group. See GS1 Application Identifiers for reading the GTIN, expiry and batch out of a scan.

Specification