What is a Data Matrix code?

The small square code on circuit boards, medicine packs and surgical tools, explained part by part.

Updated 8 min read By the Data Matrix Code Generator team

On this page 8 sections
  1. Short answer
  2. Anatomy of a Data Matrix code
  3. How it stores data
  4. Error correction (ECC 200)
  5. Where Data Matrix codes are used
  6. Plain vs GS1 DataMatrix
  7. How to make and read one
  8. FAQ

Short answer

A Data Matrix code is a two-dimensional barcode made of black and white squares (modules) in a square or rectangular grid, with a solid L-shaped border on two sides and an alternating “clock” pattern on the other two. It stores text, numbers or bytes (up to 2,335 letters and digits, or 3,116 digits) in a very small space, and uses Reed–Solomon error correction (ECC 200), so it can still be read when partly damaged. It is used to mark electronic parts, medicines, medical devices and industrial components.

Data Matrix is defined in ISO/IEC 16022 (current edition 2024). It was developed by International Data Matrix, Inc. (ID Matrix), and today anyone can make and read it. In automotive and German-speaking factories it is often called a DMC (Data Matrix Code). You need a camera-based (2D) scanner or a phone app to read one: the red-line laser scanners at older checkouts read only 1D barcodes.

Anatomy of a Data Matrix code

Every Data Matrix has the same four parts. The diagram below is a real code, made by the same engine as our generator, that encodes SN-2026-000457. Its parts are colored in to show them; a printed code is always plain black on white.

Parts of a 16 × 16 Data Matrix codeA real Data Matrix that encodes SN-2026-000457, with its four parts colored: 1 the solid L-shaped finder pattern on the left and bottom edges in dark teal, 2 the alternating clock track on the top and right edges in lighter teal, 3 the data region inside in gray, and 4 the blank quiet zone around it, shaded.1234
  1. Finder pattern (dark teal). The solid L on the left and bottom edges. It tells the scanner where the code is, which way up it is, and how big it is.
  2. Clock track (teal), also called the timing pattern. Alternating dark and light modules on the top and right edges mark out every row and column.
  3. Data region (gray). Your data plus error correction: 24 codewords of 8 modules each in this 16 × 16 size, 12 for data and 12 for error correction.
  4. Quiet zone (shaded). The blank margin. ISO/IEC 16022 asks for at least 1 module on every side; our generator defaults to 2.
A 16 × 16 Data Matrix, colored to show its parts (diagram only). Each small square is one module; sizes are counted in modules, rows × columns.

The finder and clock are why Data Matrix is so compact. A QR code spends three large corner squares on finding itself; a Data Matrix spends one module-wide line on each edge. That is also why the blank margin around it, the quiet zone, matters: if text, a label edge or another code touches the L, the scanner may not find it.

From 32 × 32 up, a single grid would be hard to keep straight, so the symbol is split into data regions, each with its own L and clock lines. A 32 × 32 code has 2 × 2 regions; the largest, 144 × 144, has 6 × 6.

A 32 × 32 Data Matrix split into 4 data regionsEach of the 2 × 2 regions is outlined. Each region has its own solid L on the left and bottom and its own alternating clock track on the top and right.
A real 32 × 32 Data Matrix, filled with 124 digits. Outlines mark its 4 data regions.

How it stores data

A Data Matrix stores codewords: numbers from 0 to 255, each drawn as a small block of 8 modules (one module per bit). The encoder turns your text into data codewords, adds error-correction codewords, and the placement rules in ISO/IEC 16022 decide where each block sits. Blocks near an edge wrap around to the opposite edge, which is why the pattern looks random.

Codeword layout of a 16 × 16 Data MatrixThe 16 × 16 symbol that encodes SN-2026-000457, drawn as a diagram. Codewords 1 to 9 hold the data, 10 to 12 are padding, 13 to 24 are error correction. Each codeword is a group of 8 modules; groups at the edges wrap around to the opposite side.123456789101112131415161718192021222324
  1. Your data: 9 codewords for “SN-2026-000457”.
  2. Padding: the unused space this size still has to fill.
  3. Error correction: 12 Reed–Solomon codewords that let a scanner rebuild damaged ones.
Left: the real 16 × 16 code. Right: the same code with each 8-module codeword tinted and numbered. Teal is data, gray is padding, lime is error correction; black and white edges are the finder and clock. Diagram only: tinted codes are not for printing.

Six ways to pack text

To use as few codewords as possible, the encoder switches between six encoding modes as it goes. You never choose a mode yourself; a good encoder picks the cheapest mix, and every ECC 200 scanner reads them all.

Data Matrix encoding modes (ISO/IEC 16022)
Mode Best for Packing
ASCIIMixed text and digits1 character per codeword, or 2 digits per codeword
C40Capital letters, digits, spaces3 characters in 2 codewords
TextLowercase letters, digits, spaces3 characters in 2 codewords
X12The ANSI X12 EDI character set3 characters in 2 codewords
EDIFACTCapitals, digits and common punctuation4 characters in 3 codewords
Base 256Any bytes: UTF-8 text, binary data1 byte per codeword, plus a length

Worked example: PART-000123

Here are the data codewords read back out of the real code for PART-000123. Letters cost one codeword each; the digits go in pairs, so the six digits cost only three. That is 8 codewords, which exactly fills the 14 × 14 size (8 data codewords, plus 10 for error correction).

Data codewords of the 14 × 14 code for PART-000123
# Codeword Means
1 81 P character code 80 + 1
2 66 A character code 65 + 1
3 83 R character code 82 + 1
4 85 T character code 84 + 1
5 46 - character code 45 + 1
6 130 00 digit pair 00 + 130
7 131 01 digit pair 01 + 130
8 153 23 digit pair 23 + 130

The code grows as you add data

An encoder picks the smallest size that fits. ECC 200 has 24 square sizes, from 10 × 10 to 144 × 144, and 6 rectangles from 8 × 18 to 16 × 48. A newer extension, DMRE (ISO/IEC 21471), adds 18 more rectangles for long, narrow spaces. The smallest square holds 6 digits; the largest holds 3,116 digits, 2,335 letters and digits, or 1,556 bytes. These codes are drawn at the same module size:

  1. 10 × 10

    6 digits

  2. 14 × 14

    PART-000123

  3. 16 × 16

    SN-2026-000457

  4. 22 × 22

    a 33-character web address

  5. 36 × 36

    100 characters of text

Real codes, drawn at the same module size. Every size is listed in the Data Matrix sizes and capacity chart.

Error correction (ECC 200)

ECC 200 is the version of Data Matrix in use today. It adds Reed–Solomon error-correction codewords to every code, the same family of math used on CDs and QR codes. The amount is fixed by the size: between 28% and 63% of a square or standard rectangle’s codewords are error correction. A reader can rebuild up to half that many wrong codewords.

Error correction in four ECC 200 sizes (ISO/IEC 16022 size table)
Size Codewords Error-correction codewords Wrong codewords it can fix
10 × 10 8 5 (63%) up to 2
16 × 16 24 12 (50%) up to 6
32 × 32 98 36 (37%) up to 18
144 × 144 2,178 620 (28%) up to 310

Those are codewords, not a share of the printed area. How much physical damage a code survives depends on where it is: a smudge inside the data region may cost a few codewords and still read, while a scratch through the finder L or the quiet zone can stop the scanner finding the code at all. So nobody can promise a fixed “percentage of damage” for every code. The ECC 200 explained guide goes further. The older versions, ECC 000 to ECC 140, used a different, weaker scheme and are obsolete; this site makes ECC 200 only.

Where Data Matrix codes are used

Data Matrix wins wherever space is tight or the code has to last. You will find it on:

  • Electronics and parts. Circuit boards, chips and connectors, where a code a few millimeters across holds a serial or part number.
  • Direct part marking. Automotive and aerospace parts with the code laser-etched or dot-peened into metal, so it lasts as long as the part.
  • Medicines. Prescription medicine packs in the EU and US carry product code, serial, batch and expiry in a Data Matrix.
  • Medical devices. Unique Device Identification (UDI) labels, often in GS1 DataMatrix on small instruments and implants.
  • Assets and inventory. Asset tags, bins, totes and sample tubes, where the code has to fit on a narrow label.
  • Postage and documents. Postage printed from a computer and tracking marks on forms and tickets in several countries.

The rules behind the medicine codes are specific: the EU Falsified Medicines Directive’s Delegated Regulation (EU) 2016/161 requires a Data Matrix on prescription medicine packs, and the US Drug Supply Chain Security Act asks for the product identifier in a 2D Data Matrix on each package. Most of these codes follow the GS1 format described below.

Plain Data Matrix vs GS1 DataMatrix

A GS1 DataMatrix is the same symbol with two extra rules: it starts with a special FNC1 character, and its content is a chain of GS1 Application Identifier fields, such as (01) for the product number (GTIN) and (17) for the expiry date. A plain Data Matrix holds any text you like, and only your own system knows what it means.

Plain vs GS1 DataMatrix
Feature Plain Data Matrix GS1 DataMatrix
Content Any text or bytes GS1 fields: GTIN, batch, expiry, serial…
Example PART-000123 (01)09506000134352(17)281231(10)LOT42(21)SN1001
Scanner says ]d1 (or nothing) ]d2, fields split by a group separator
Use for Your own parts, assets, serials Products sold or shipped to others: medicines, devices, retail

The brackets in the printed line are for people; they are not encoded. The full story, with field-by-field examples, is in GS1 DataMatrix explained.

How to make and read one

  • One code: make a Data Matrix code in the generator. Type your text, then download a PNG, SVG or true-size PDF. It runs in your browser and needs no sign-up.
  • Many codes: the bulk generator takes a list, a CSV or an Excel file, or makes serial numbers for you.
  • GS1 product codes: the GS1 DataMatrix generator checks the GTIN, dates and separators.
  • Reading: read a Data Matrix code from a photo or your camera in the browser. Phones can also use a barcode scanner app; built-in camera apps are made for QR codes, and their Data Matrix support varies. Handheld 2D imagers read Data Matrix; 1D laser scanners cannot.

Wondering whether you need a QR code instead? See Data Matrix vs QR code, which encodes the same data in both and measures them.

Frequently asked questions

What is a data matrix code?
A Data Matrix code is a two-dimensional barcode: a square or rectangle of small black and white squares (modules) with a solid L-shaped border on two sides and an alternating “clock” pattern on the other two. It stores text, numbers or raw bytes, up to 2,335 letters and digits or 3,116 digits, and its built-in Reed–Solomon error correction (ECC 200) lets scanners read it when part of it is damaged. It is defined in ISO/IEC 16022.
Can you provide an example of data matrix code?
Yes. The code at the top of the anatomy section encodes SN-2026-000457, and the Data Matrix examples page has real, scannable samples (part number, serial, web address, GS1 product data, rectangular and DMRE sizes) with the exact data inside each one, as SVG or PNG downloads and a printable test sheet.
What is a Data Matrix company?
Data Matrix is a type of barcode, not a company. It was developed by International Data Matrix, Inc. (ID Matrix) and is now a public standard, ISO/IEC 16022, that anyone can use. Many companies make Data Matrix printers, scanners and software. You may also see the name Semacode, an older system that put web links in Data Matrix codes; the code itself is the same.
What does DMC mean on a part?
DMC stands for Data Matrix Code. The abbreviation is common in automotive and German-speaking manufacturing, where parts carry a DMC marked straight onto the metal or plastic (direct part marking) to trace each part through production.
How do Data Matrix codes work?
The encoder turns your text into codewords (bytes), adds Reed–Solomon error-correction codewords, and places each codeword as a block of 8 modules inside a frame of finder and clock patterns. A camera-based scanner finds the L-shaped border, uses the clock track to count rows and columns, reads the modules back into codewords, fixes any damaged ones, and turns them back into your text.