How much more “data” does a QR code have, compared to a regular “bar code/UPC code”?

1.46K views

I kind of understand how a UPC code works, but how is a QR code capable of “storing more data”?

In: Other

10 Answers

Anonymous 0 Comments

A UPC code stores precisely 8 digits and it does so only with vertical lines, with various combinations of black or white representing specific values. A QR code does this process over a whole grid, meaning there is simply space for more digits – the most dense version of the QR standard can store 7089 digits.

Anonymous 0 Comments

All barcodes have what is known as error correcting codes. This is extra information added to correct most typical read errors. For example in an UPC code you can get away with only having four modules per digit this would cause a lot of errors so they have seven modules per digit making it easier to read. This makes it 47% efficient. In addition there is a check digit which further reduce the efficiency. You would think that using bars instead of a matrix would reduce efficiency but this is not the case since the bars can be very short which means you can have as much information in the same place if you use multiple barcodes stacked on top of each other.

For QR codes however the amount of error correcting code in the pattern and therefore its density can be selected freely. So it is up to the people encoding the QR code to set how easy it should be to scan. You can create a very big pattern with lot of error correcting codes or a tiny pattern with the same data but which can be hard to scan if damaged.

Anonymous 0 Comments

If you think about what a UPC code is, it’s just a series of black and white lines, right? Each of those lines can be represented as a binary digit, a 1 or a 0, depending on whether it’s black or white. If you only cared about a binary string, that’s all you’d need. You could make a barcode that was 4 digits long by having 4 lines. If B is 0 and W is 1, then 4 lines of BWWB will be read as 0110. However, this isn’t super convenient, so UPC organises these lines into blocks of 7, and uses the order of the lines to represent a decimal digit. 1110010 for example represents 0.

But, those lines don’t actually need to be very long. The vertical dimension in a UPC code is doing absolutely nothing in terms of the information it delivers, it’s just making it so the line of light from the barcode reader doesn’t need to be perfectly aligned – it’s making it much easier to scan. So, you could squish a barcode down to be potentially even just 1 atom tall if you really wanted to and could invent a reader capable of seeing something that small. With the shift to cameras, which can see the actual image and not just detect the red line bouncing off it, the height of the barcode can be shrunk down immensely. This is pretty much what a QR code is doing – by shifting to squares instead of lines, it can fit a lot more information in, because it frees up the vertical dimension to contain different information to the bits of the code above and below it.

Anonymous 0 Comments

So there’s a few concepts at play.

The first is that a UPC code is a “2D barcode”. That means the data is read left-to-right and nothing about the up-and-down direction has to do with the data. A QR code is a “3D barcode”. That means it uses both directions to encode data.

So a 2D barcode is like one row of pixels on your monitor, and the QR code is like the entire monitor. That alone should tell you QR has the potential to store a TON more data and why.

“How much more does it have” is kind of complicated, so we’ll stick with the simple parts. The most common specification for UPC lets you encode a 12-digit number. The largest possible specification for QR lets you encode a 7,089-digit number. That’s a lot!

In theory we could make both bigger and fit more data in them, but since UPC can only “grow” in one direction, it’ll always have less data than a QR of a similar size.

Anonymous 0 Comments

First off a UPC is a specific standard of writing a barcode:

A barcode uses 7-bit character encoding and can be made to any length necessary, the data would be length(n) of the code * 7, eg. a 20 character barcode would be 20×7 = 140bit

A UPC is an international standard(technically UPC-A) length barcode of 12 characters, so 12*7 = 84bits

Note: 7-bit character encoding carries far more possible data than a binary representation of 0-9 which would only require 4bits per number

Now for QR codes:

Data is represented in a 177×177 grid of “pixels” for each bit, 177×177=31,329 bits. Data in a QR code in encoded into 8-bit bytes instead of the 7-bit used in barcodes, so 31,329/8=3,916 bytes. Bytes to data rate conversion 3,916/1,024=3Kb

TL;DR a QR code can hold 372 times as many bits of binary data as a standard UPC-A code.

Anonymous 0 Comments

UPC, specifically UPC-A, is a series of line of varying thickness representing 25 bits to encode a 12-digit number

QR code is a series of black squares presented in a grid that can represent up to a 7089-digit number with 23624 bits.

So if you’re strictly speaking of data then a QR code can have 23599 more bits of data.

When you start encoding different types of information then it varies. There are multiple ways of encoding data into a QR code across the many iterations of the specification.

Anonymous 0 Comments

Imagine if you made a document in something like Word, and you pasted in a barcode image on one line, then hit Return and pasted a different barcode on the next line, then hit Return and pasted a different barcode on the next line, and so on. Line after line of barcode images. Now imagine if you didn’t have to make those barcodes very tall – if you could squish the images’ height down so each one is short but still wide. Now you take those lines of squished barcodes and remove the spacing between the lines of the document so they butt up against each other. Now you have a little rectangular block made of multiple rows of barcodes. That’s *sort of* what a QR code is doing (*not exactly, because there’s other blocks embedded in the middle to help with formatting and fixing alignment in case the image is bent or folded, and QR codes use a lot more redundancy for error detection and repair, so “rows of barcodes” is only *sort of* what QR is doing.*)

Now imagine if you print this document out on paper, and then cut out the square with the codes and hand that to someone to decode. One problem they’d have is that they don’t know which way was “up” on the paper in the first place because you cut it into a square. I’m sure you’ve seen that QR codes always have this big ugly box in 3 of the corners but not all 4 corners. That’s to solve this problem of which way is up on the image. It tells the computer which way to rotate the image in its head before decoding it. It should rotate it so the corner without the big box is in the lower-right.

As to how much more it can hold than a UPC code, that question isn’t simple because there’s multiple UPC code standards and multiple QR code standards. You may see numbers quoted like 7000 different digits, but keep in mind that that refers to the biggest most dense QR codes which are not usually what you’ll find in general public usage. What you typically find in consumer usage only holds a hundred or so digits. Usually that’s enough to encode a basic alphanumeric string for a web URL, as long as it’s not super super long. (An address of about 50 chars or less).

As to why not use the denser format? Well, because it’s easier to get a “good scan” when the image is clunkier and blockier. It makes it a lot more tolerant of noise. For things like labels on store products, or images quickly snapped with a mobile phone, that tolerance of noisy images is important.

Anonymous 0 Comments

Thanks for all of the in-depth explanations. I have a better understanding of it now, thanks to y’all. It still blows my mind, lol.

Anonymous 0 Comments

A non-technical ELI5 explanation.

A barcode only stores data horizontally, while a QR code stores data both horizontally and vertically.

Take a barcode that has 5cm width and 5cm height, it can only store 5cm of data, even though the height of the barcode is also 5cm.

A QR code that is 5cm width and 5cm height, however, can store 5cm * 5cm = 25cm² worth of data.

It may not be technically correct, but it’s good enough for a 5 years old.

Anonymous 0 Comments

An important part of this to recognize is that a normal bar code doesn’t really store much info. It has a number, which then has to go into someone’s database to find the details for what the number represents. There’s nothing wrong with that, but they all require third-party access to be useful.

A QR code instead has all of the data in the image itself, as others in this thread have explained very well. The cool part is that *no one owns that data*. It doesn’t need to go to some other source to look it up, and no entity controls what data is in there. Google and Apple and others have scanners, but those literally pull the data from the code and then do what’s requested (often opening their browser to the URL from the code).

This is why I rather dislike things like the Snapchat QR codes; they’re not bad, per se, but they’re proprietary and require Snapchat’s database for them to work, not unlike a normal bar code.

As a fan of the open internet (RSS, etc), I like the concept of QR codes being something that no big entity can own.