Unlike 1D codes where all information can be found in one cut through the code, 2D codes need a second dimension since they contain many different ‘lines’ of data. Among the most popular 2D codes are the QR codes and Data Matrix. QR code was created by Denso Wave in 1994 and Data Matrix was invented by ID Matrix around 2005. The Data Matrix that is in popular use is the EC200 (there are other variations less popular). Both can be used free of any licensing or royalties, and hence their popularity. In this post I would like to compare these two codes and see when one of them might be more suitable to use than the other.

## General structure

Both codes contain areas of data and recognition areas that helps to detect the code and inform the decoder how to decode it (like version, masks etc). Both of them use the Reed Solomon system to recover damaged part of the code data. Here are typicals QR code and Data Matrix with their non-data areas marked in red.

From first sight it is quite obvious that QR codes has more recognition area than Data Matrix (which uses only its perimeter for this purpose). The Data Matrix to the right uses only 84 modules of its 22×22 modules (17%) as recognition area, while the QR code to the left uses 228 modules of its 29×29 (27%) as recognition area. It means that Data Matrix has 10% more of its area available for data and hence they are more compact in size and more effective – using less area to contain same amount of data.

When this may be the situation in few cases, it is not always so. Let’s see why and when one of these codes is more appropriate to use than the other.

## Versions and recognition data

Both QR codes and Data Matrix modules will grow by steps as data is added. These steps create what is called versions of the codes. For QR code the smallest possible version has 21×21 modules, when Data Matrix smallest version is 10×10 modules. QR codes grow in steps of 4 modules in each direction for every version until its final version 40 which is 177×177 modules. Data Matrix grows in steps of 2 modules in each direction with some gaps and even few rectangular codes where the number of modules in each direction is different. Its largest size has 144×144 modules.

QR codes add an overhead of a fixed size (the finder patterns) and a varying size (the time lines) that grows with the version of the QR code. The overhead area of Data Matrix on the other hand is totally dependent on its version. It is should be easy than to see when QR codes will become more effective in data/area ratio.

QR code overhead is:

7x7x3 (the finder patterns)

5×5 (the guiding pattern)

29 modules – the version and mask information

2(L – 14) – the timelines (where L is the number of modules in each direction)

Data Matrix overhead is 4L-4 (where L is the number of modules in each direction)

To see when QR codes overhead area will be smaller than Data Matrix overhead area we have to find the smallest L that fits into the following equation 4L-4 > 7x7x3 + 5×5 +29 +2L-28

This starts happening when L is 89 modules. For QR code it means version 18. Version 18 can contain 721 characters or more than 1900 digits. For example a typical business card contain between 60-150 characters, which means that Data Matrix is more suited for business cards than QR codes.

Here is a QR code with some contact data and a Data Matrix with exactly the same data.

The QR code has 37×37 modules (version 5) while the Data Matrix has 40×40 modules.

Surprise! How is this possible? It is truth that 2 additional lines of recognition area were added to the Data Matrix (the vertical and horizontal lines in the center) but still the Data Matrix should have been with much less modules than the QR code.

The reason for this resides in the Error Correction levels. The EC of all Data Matrix in all versions is around 30% when QR codes have 4 different EC levels. The QR code in the left has only 7% additional data area for EC while the Data Matrix has 30% additional data for EC. The additional 23% cause the Data Matrix to be larger than the QR code at the end.

## When Data Matrix may be the better choice

1- The lowest version of Data Matrix is 10×10 modules, so whenever you are tight in print area and your encoded message is short enough to go into a 10×10 to 20×20 Data Matrix – go for Data Matrix.

2- Whenever you need to put your logo or any other image on your 2D code, and printing size matters – consider Data Matrix.

Here are the same codes as above with a logo in the maximum possible size for each of them.

The only reason for the difference in logo size is the Error Correction level. Same size of logo will work for a QR code with a High Error Correction (30%) – only the QR code version will be higher and therefore with a bigger print area.

Note: It is not a good idea to use all of EC power when drawing on a 2D code. You should always leave some extra safe zone for unexpected damage to the code or to the images that will reach decoders.

## When QR codes may be a better choice

1- Whenever you are tight in print area and your encoded message goes into a Data Matrix of size 22×22 or more go for QR codes with a low or medium EC.

2- Whenever the esthetic of your code matters, QR codes have an advantage over the Data Matrix due to their finding patterns and general look. For some reason decorated QR codes look better than decorated Data Matrix.

3- QR codes has few modes of encoding data, some of them are more compact than the 8 bits for character used by Data Matrix. In situation when an encoding mode with low EC gives you a smaller print area, go for the QR code.

## Readers for Data Matrix

Many readers that support QR codes support also Data Matrix.

Here is a list of these readers.

i-nigma

NeoReader

ScanLife

MobileTag

BeeTagg

QuickMark

Lynkee

Google

iSite TV

UpCode

For Android devices you can find also – Barcode Scanner, wBarCodesList, ixMat, BaroScan

By the way – I’m sure there are other readers for Data Matrix that I am not aware of.

This was a very helpful post and blog in general. I used the info here to read a QR Code on the CBS TV show, Person of Interest. In the show, a QR Code is “hidden” in two pieces (bottom half from the front and top half from the back). The only way to read the code is to capture the images and piece them together. The QR Code links to a real estate advertisement that has nothing to do with the show except perhaps where it was filmed. Is it accidental product placement or is some kind of secret clue?

See it here:

http://www.person-of-interest.net/episodes/cura-te-ipsum-t8.html

Hello Ken

As a rule of thumb you can put two QR codes on the same page as long as the distance between the center of one QR code to the far edge of the second is more than half the maximal distance for reading the QR code in the center.

Many QR codes on the same page appears quite a lot in magazines in japan. Sometimes they are very close. People tend to solves this quite easily by putting a finger on the bar-code they do not want to scan.