Introduction
Data Matrix is a 2D barcode standard (ISO/IEC 16022) that encodes data in a square or rectangular grid of black and white modules. It is used in electronics manufacturing (PCB marking), pharmaceuticals (FDA drug traceability), and logistics for its ability to encode up to 2,335 alphanumeric characters in a compact symbol. Unlike QR codes, Data Matrix symbols can be as small as 2x2 mm while remaining readable. This tool generates Data Matrix barcodes in your browser using the bwip-js library.
What this tool does
- Generates Data Matrix 2D barcodes from text or binary input
- Renders directly to a canvas element for immediate preview
- Supports adjustable scale (pixels per module) for print sizing
- Handles ASCII, extended ASCII, and UTF-8 data
- Uses the bwip-js library, a JavaScript port of Barcode Writer in Pure PostScript
How this tool works
The tool uses bwip-js, which is a JavaScript port of BWIPP (Barcode Writer in Pure PostScript). When you enter data, the tool calls bwip.toCanvas() with the bcid "datamatrix", the input text, and a scale parameter. The library renders the Data Matrix symbol directly onto an HTML canvas element. The scale parameter controls how many pixels each module (cell) occupies, which determines the physical size of the printed barcode. The tool includes padding around the symbol for quiet zone requirements. The canvas updates on every keystroke, so you see the barcode change in real time as you type.
How Data Matrix barcodes work
Data Matrix encodes data using a combination of Reed-Solomon error correction and a proprietary encoding scheme. The symbol consists of an L-shaped finder pattern (one solid border on the left and bottom) and an alternating timing pattern on the opposite borders, which allows scanners to determine the grid size and orientation. Data is encoded in a zigzag pattern through the grid. The encoding algorithm selects the most compact representation for each character: ASCII digits are encoded in 4 bits, ASCII uppercase in 5 bits, and full ASCII in 7 bits. Reed-Solomon error correction allows the symbol to be read even if up to 30% of it is damaged. The ECC 200 variant is the most common and is what bwip-js generates. Data Matrix was invented by International Data Matrix, Inc. (ID Matrix) in 1989 and standardized as ISO/IEC 16022 in 2006.
How to use this tool
- Type or paste the data to encode in the input box.
- Adjust the scale slider to control the pixel size of each module.
- The Data Matrix barcode renders automatically on the canvas below.
- Right-click the canvas to save the image as PNG for printing or embedding.
- Verify the barcode with a scanner before using it in production.
Real-world examples
Marking PCBs for electronics manufacturing
Electronics manufacturers use Data Matrix to mark PCBs with serial numbers because the symbol can be as small as 2x2 mm and still be laser-etched and machine-readable. Enter a serial number like "SN20260810A001" and set scale to 3 for a compact symbol suitable for etching.
Pharmaceutical traceability (FDA DSCSA)
The FDA Drug Supply Chain Security Act (DSCSA) requires pharmaceutical packages to carry a 2D barcode with the National Drug Code, serial number, lot number, and expiration date. Data Matrix is the standard format. Enter the combined data string and generate the barcode for packaging artwork.
Asset tracking in logistics
Warehouse management systems use Data Matrix for asset tags because the symbol remains readable even when partially obscured or damaged, thanks to Reed-Solomon error correction. Generate barcodes for asset IDs and print them on labels for scanning with handheld imagers.
Comparison with similar methods
| Method | Complexity | Typical use |
|---|---|---|
| Data Matrix (ISO/IEC 16022) | Reed-Solomon + proprietary encoding | Electronics, pharma, small labels |
| QR Code (ISO/IEC 18004) | Reed-Solomon + structured append | Marketing, URLs, payments |
| PDF417 (ISO/IEC 15438) | Stacked 1D + Reed-Solomon | Driver licenses, boarding passes |
| Aztec (ISO/IEC 24778) | Reed-Solomon + center finder | Transport tickets |
Limitations or considerations
The tool generates ECC 200 Data Matrix symbols. The maximum data capacity depends on the symbol size: a 10x10 symbol holds 3 numeric or 1 alphanumeric character, while a 144x144 symbol holds 3,116 numeric or 1,556 alphanumeric characters. Very large data inputs may produce symbols too large to display on screen at high scale. The canvas rendering is raster (PNG), not vector, so scaling up after generation produces pixelation. For vector output, use a library that generates SVG.
Frequently asked questions
What is the difference between Data Matrix and QR codes?
Data Matrix symbols can be much smaller (down to 2x2 mm) and are preferred for direct part marking in manufacturing. QR codes are larger but more widely recognized by consumer apps and support larger data capacities. Data Matrix uses an L-shaped finder pattern; QR codes use three corner squares.
What is ECC 200?
ECC 200 is the most common Data Matrix variant, using Reed-Solomon error correction. It is the standard used in FDA drug traceability and GS1 DataMatrix. Older variants (ECC 0-140) use convolutional error correction and are rarely used today.
How much data can a Data Matrix hold?
Up to 3,116 numeric digits or 2,335 alphanumeric characters in the largest symbol size (144x144 modules). The actual capacity depends on the data type: numeric data is more compact than alphanumeric, which is more compact than binary.
Can I scan the generated barcode with my phone?
Most modern phone cameras can scan Data Matrix barcodes, though some default camera apps may not support it. Dedicated barcode scanner apps like ZBar or the Google Lens app can read Data Matrix symbols reliably.
Conclusion
Data Matrix is the standard 2D barcode for electronics manufacturing, pharmaceutical traceability, and small-label applications. This tool generates ECC 200 symbols in your browser using bwip-js. Adjust the scale for print sizing and verify with a scanner before production use.