EAN Check.comEAN Check.com

Data Matrix Generator

Make a Data Matrix code from any text, or a GS1 DataMatrix from a GTIN with batch, expiry and serial data, and download it as SVG, PNG, EPS or PDF. GS1 data is checked against the Application Identifier rules before you print.

By The eancheck teamPublished

What a Data Matrix is

A Data Matrix is a square or rectangular two-dimensional barcode made of black and white cells, called modules. It holds far more than a linear barcode in far less space, which is why it is printed on circuit boards, surgical instruments, aircraft parts and medicine packs. The current version, ECC 200, is standardised as ISO/IEC 16022.

You can recognise one by its edges. Two sides form a solid L, which tells a scanner where the code is and which way up it sits. The other two sides alternate black and white, so the scanner can count the rows and columns. Everything inside is data plus error correction, which lets a scanner rebuild what a scratch or a smudge has hidden.

Plain Data Matrix or GS1 DataMatrix

A plain Data Matrix holds whatever text you give it: a serial number, a part number, a web address. A GS1 DataMatrix holds data written in the GS1 format, where each value has a number in brackets in front of it that says what it is. Tick GS1 data in the generator and type the data like this:

(01)09506000134352(17)271231(10)ABC123(21)SN000042

AIMeansFormat
(01)The product's GTIN (Global Trade Item Number)14 digits, valid check digit
(17)Expiry dateYYMMDD
(10)Batch or lotUp to 20 characters
(21)Serial numberUp to 20 characters

The example reads: GTIN 09506000134352, expiry 31 December 2027, batch ABC123, serial SN000042. Have a 12 or 13 digit number? Put zeros in front to make 14 digits, and check it first with the check digit calculator.

The generator checks each AI before drawing: a wrong GTIN check digit, an impossible date or an over-long batch stops it with a message that names the AI. To check a string you received from a supplier, paste it into the GS1-128 parser; for a whole list, use the bulk GS1 parser.

Separators and scanners

The brackets are only for people. Inside the code the generator writes the AIs without them, starts the code with an FNC1 character that marks it as GS1 data, and puts a separator after each variable-length value that has another value after it. In the example above that is one separator, after the batch ABC123. The GTIN and the date need none, because they always have 14 and 6 digits, and the serial needs none because it is last.

The GS1 General Specifications allow either FNC1 or the GS character (ASCII 29) as that separator, and a scanner reports both as GS. Some label programs make you type FNC1 as an escape code such as \F. Here you type the brackets and the generator places FNC1 where it belongs.

Most trouble starts at the scanner. A scanner that types into a spreadsheet or a web form often drops the GS character, so ABC123 and 21SN000042 run together into one value. Set the scanner to send GS, or a substitute character your software expects, and turn on the symbology identifier ]d2 so the software knows the data is GS1. Test with a code from this page before you print a batch. If you are unsure what a scanned string is, the barcode identifier recognises GS1 strings.

How big will it be?

The printed size is the number of modules times the module size you pick. A Data Matrix grows in steps as the data grows, from 10 by 10 modules up to 144 by 144. These sizes come from this generator at 0.5 mm per module, including the 1-module quiet zone:

DataModulesSize at 0.5 mm
12-digit number14 × 148 mm
Serial SN 12345 LOT 716 × 169 mm
GS1: GTIN, expiry and batch20 × 2011 mm
GS1: GTIN, expiry, batch and serial22 × 2212 mm
GS1: the same as a rectangle36 × 1619 × 9 mm
50-character web address26 × 2614 mm
100 digits32 × 3217 mm

Type your own data below to see its module count and its printed size at the module sizes GS1 uses.

Data Matrix size for your text

Working it out…

Size without the one-module quiet zone. Module sizes from the GS1 symbol specification tables.

Module size for GS1 data

For your own labels, 0.33 to 0.5 mm per module reads well with handheld scanners and phones. GS1 data has its own sizes in the GS1 General Specifications, set by where the code is scanned:

Where it is scannedSmallestTargetLargest
Products sold at a till, including pharmacy0.396 mm0.495 mm0.990 mm
Medicines and medical products not sold at a till0.254 mm0.380 mm0.990 mm
Cartons and pallets in warehouses0.743 mm0.743 mm1.50 mm

The generator warns when GS1 data is set below 0.396 mm. That is fine on a hospital label, but too small for a pack sold in a shop. GS1 gives these figures in millimetres; if a US customer specifies mils, switch the units in More settings (0.396 mm is about 15.6 mils).

Square or rectangle

Never stretch a square code in a design program. If the space is long and thin, such as a cable tag, the edge of a circuit board or the side of a small tube, choose Rectangle under Data Matrix shape in More settings. The generator then uses one of the six rectangular sizes in ISO/IEC 16022, from 8 by 18 to 16 by 48 modules. Rectangles hold less: the largest takes 98 digits or 72 letters and digits. For more, use a square.

Printing a Data Matrix

On an office printer, download the PDF and print it at 100% (actual size), not "fit to page". Print the test page from the download menu first and measure its 100 mm ruler: if the ruler is not 100 mm, the printer driver is scaling and your code is the wrong size too.

Thermal label printers print in whole dots, so pick the label printer preset with your printer's resolution and the generator snaps each module to a whole number of dots. At 203 dpi one dot is 0.125 mm. A module of 0.396 mm becomes 3 dots, which is 0.375 mm and under the GS1 minimum for retail packs; set 0.5 mm instead, which is exactly 4 dots. At 300 dpi, 0.396 mm becomes 5 dots, 0.423 mm.

Keep dark modules on a light background. The colour settings show a contrast figure for scanners and warn when it is too low, which matters on dark packaging and coloured labels.

Data Matrix, QR code or a linear barcode?

Data Matrix

For anything small, anything marked directly on a part, and anything scanned by warehouse or production scanners. For short data it is usually smaller than a QR code: it needs a quiet zone of one module where a QR code needs four, and its smallest size is 10 by 10 modules against 21 by 21. Its error correction makes it hard-wearing.

QR code

For packaging that consumers scan with a phone. Under GS1 Sunrise 2027, shop scanners should read 2D codes by the end of 2027; for consumers the usual choice is a QR code holding a GS1 Digital Link address with the GTIN inside. Build one with the Digital Link generator, or a whole catalogue with the bulk Digital Link generator. Either 2D code goes next to the EAN or UPC, not instead of it.

Linear barcode

When the label has room and older laser scanners must read it, a Code 128 holds a short serial number, and GS1-128 holds GS1 data. Laser scanners cannot read a Data Matrix; camera-based scanners read both.

Medicines and medical devices

Prescription medicines in the EU have carried a 2D Data Matrix since 9 February 2019, under Regulation (EU) 2016/161. It holds the product code, serial number, batch and expiry date, plus a national reimbursement number where a country requires one, so a pharmacy can check each pack against a central register before handing it over.

In the USA, the Drug Supply Chain Security Act requires a 2D Data Matrix on prescription drug packages, with the product identifier, serial number, lot and expiry. Medical devices are different: the FDA's UDI rule asks for the unique device identifier in plain text and in any machine-readable form, so a linear barcode, a 2D code or RFID all qualify. GS1 DataMatrix is one common choice, not a requirement.

Frequently asked questions

How much data fits in a Data Matrix?

Up to 3 116 digits, 2 335 letters and digits, or 1 556 bytes of other data in the largest square, 144 by 144 modules. This generator stops at 2 000 characters, which covers serial numbers, URLs and GS1 strings with room to spare. Short data makes small codes: 12 digits fit in 14 by 14 modules. The largest rectangle, 16 by 48, holds 98 digits.

What is the difference between Data Matrix and GS1 DataMatrix?

The symbol is the same. A GS1 DataMatrix starts with a special FNC1 character and holds data written as GS1 Application Identifiers, such as (01) for a GTIN, (17) for expiry and (10) for batch. Scanners then hand the data to systems that understand the AIs. Tick GS1 data in the generator and type the AIs in brackets for that format.

How small can a Data Matrix be?

As small as your printer and scanner allow. At 0.25 mm modules, the smallest setting here, a 12-digit code is 4 mm square including its quiet zone. For a GS1 DataMatrix on products sold in shops, GS1 asks for at least 0.396 mm per module, and the generator warns below that. Healthcare items not scanned at a till may go down to 0.254 mm.

Can a damaged Data Matrix still be read?

Often, yes. Every Data Matrix ECC 200 code carries Reed-Solomon error correction, so a scanner can rebuild data hidden by a scratch, a smudge or a missing corner. How much damage it survives depends on the symbol size and where the damage is; the L-shaped edge must stay readable, because the scanner uses it to find the code.

Should I use Data Matrix or a QR code?

Data Matrix for small parts, medicines and labels read by industrial or warehouse scanners. It is usually smaller than a QR code for short data, because it needs only a one-module margin and its smallest size is 10 by 10 modules. QR codes suit consumers scanning with a phone camera, and GS1 Digital Link QR codes can carry the same GTIN data in a web address.

Why does my GS1 DataMatrix show an error?

The data does not follow the GS1 rules. Common causes are a GTIN with a wrong check digit in (01), a date in (17) that is not six digits as YYMMDD, a batch in (10) longer than 20 characters, or text before the first AI. The message names the AI and the problem, so you can fix that one value.

Why does my scanner show strange characters or run the GS1 data together?

Because of the hidden separator. Inside a GS1 DataMatrix the GS character (ASCII 29) ends each variable-length value, such as a batch. Many scanners in keyboard mode cannot type that character, so it vanishes or shows as a symbol, and the batch runs into the serial number. Set the scanner to send GS or a substitute your software expects, and turn on the ]d2 prefix.

In what order should I put the AIs?

Fixed-length ones first, such as (01) GTIN and (17) expiry, then variable-length ones such as (10) batch and (21) serial. A fixed-length value needs no separator and the last value never does, so this order saves a separator. For short data the size rarely changes: the four-AI example on this page is 22 by 22 modules either way. The generator keeps the order you type.

Can I put my own SKU in a GS1 DataMatrix?

Not on its own. A GS1 DataMatrix holds only GS1 Application Identifiers, so a bare SKU such as AB-12345-01 is rejected when GS1 data is ticked. For internal codes, untick it and make a plain Data Matrix. If you need both, GS1 keeps AIs 91 to 99 for company internal information, so (01) with your GTIN plus (91)AB-12345-01 is valid.

Can an expiry date end in 00?

Yes, outside healthcare. In GS1 data, day 00 means the last day of the month, so (17)271200 means the end of December 2027. Since 1 January 2025 the GS1 General Specifications do not allow 00 as the day for regulated healthcare products such as medicines and medical devices; they need a real date. A full date avoids confusion on any product.

By The eancheck teamPublished

Questions or corrections? Email the eancheck team.