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.
- 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.
- 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.
- 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.
- Quiet zone (shaded). The blank margin. ISO/IEC 16022 asks for at least 1 module on every side; our generator defaults to 2.
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.
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.
- Your data: 9 codewords for “SN-2026-000457”.
- Padding: the unused space this size still has to fill.
- Error correction: 12 Reed–Solomon codewords that let a scanner rebuild damaged ones.
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.
| Mode | Best for | Packing |
|---|---|---|
| ASCII | Mixed text and digits | 1 character per codeword, or 2 digits per codeword |
| C40 | Capital letters, digits, spaces | 3 characters in 2 codewords |
| Text | Lowercase letters, digits, spaces | 3 characters in 2 codewords |
| X12 | The ANSI X12 EDI character set | 3 characters in 2 codewords |
| EDIFACT | Capitals, digits and common punctuation | 4 characters in 3 codewords |
| Base 256 | Any bytes: UTF-8 text, binary data | 1 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).
| # | 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:
-
10 × 10
6 digits
-
14 × 14
PART-000123
-
16 × 16
SN-2026-000457
-
22 × 22
a 33-character web address
-
36 × 36
100 characters of text
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.
| 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.
| 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.