Sign in to save

Bookmark this page so you can find it later.

Sign in to save

Bookmark this page so you can find it later.

A QR code is a two-dimensional barcode that stores information in a grid of black and white squares. It matters because a phone camera can read it quickly even when the code is small, rotated, or partly damaged. QR codes are used for website links, tickets, payments, inventory labels, and classroom activities because they connect physical objects to digital data.

Their power comes from combining simple pixel patterns with careful rules for locating, encoding, and checking data.

When a scanner sees a QR code, it first finds the large square position markers and uses them to measure the code's size, angle, and perspective. The data bits are stored as dark and light modules arranged in a zigzag pattern, along with format information that tells the scanner how the code was masked and how much error correction is included. Error correction uses extra mathematical data so the original message can often be recovered even if part of the QR code is dirty or hidden.

After unmasking and error correction, the scanner converts the bits back into text, a URL, or another data type.

Understanding How QR Codes Work

Before a QR code is placed into a grid, its message is prepared in a compact form. A web address becomes a sequence of computer values. A phone number, plain text, or contact card uses its own set of rules.

The generator chooses an encoding mode that fits the content. Digits can be packed more efficiently than general text, so a long number may need less space than the same number written as characters. One message can use several sections with different modes.

Small control fields tell the reader how to interpret each section and how many characters it contains. This is why changing one character in a link can change many squares.

The layout contains more than message space. QR codes come in numbered sizes, called versions. Larger versions have more rows and columns, which allows more data but makes each small square harder for a camera to separate.

Repeating timing lines help a reader count positions across the grid. Larger codes include extra alignment patterns near the middle or edges. These help when a code is printed on curved packaging or photographed at an angle.

A clear empty border around the outside is important too. This quiet zone separates the code from nearby writing, borders, or pictures. Without it, a reader may mistake surrounding marks for part of the grid.

A generator has another important job before it creates the final image. It tries several masking patterns that flip selected light and dark squares according to fixed rules. The message stays the same after this process because the reader knows how to reverse the chosen pattern.

Masking prevents large patches or long lines of one colour. Such patterns can confuse a camera or make the code harder to measure. The generator scores each option and selects one with a balanced-looking layout.

A scanner then has to deal with real camera problems, including shadows, glare, blur, low resolution, and uneven brightness. It estimates a sampling grid so that each camera region is classified as light or dark. This is why a sharp, well-lit image is easier to read than a tiny code on shiny paper.

QR codes are useful because they carry data, but the data itself is not automatically trustworthy. A code can contain a web address that leads to a fake sign-in page, a payment request, or a download. A familiar logo printed beside a code does not prove where it goes.

Students should check the destination shown by a scanning app before opening it, especially for payment or account links. Some codes are static, meaning their stored message never changes. Others point to a redirecting service, so the final destination can be changed later and may collect scan information.

When learning this topic, pay attention to the difference between encoding data and acting on data. The code is a storage format.

The phone app, browser, or payment app decides what happens next. Printed links or another access method are important for people who cannot scan a code easily.

Key Facts

  • A QR code stores data in modules, which are the small square units of the grid.
  • Binary encoding uses dark and light modules to represent bits, where each bit is 0 or 1.
  • Finder patterns are the three large corner squares that help the scanner locate and orient the code.
  • Reed-Solomon error correction adds extra codewords so damaged or missing data can be reconstructed.
  • QR capacity depends on version, error correction level, and data mode, such as numeric, alphanumeric, byte, or kanji.
  • Higher error correction improves damage resistance but reduces the space available for the actual message.

Vocabulary

Module
A module is one small square cell in a QR code grid that is read as dark or light.
Finder pattern
A finder pattern is one of the large square markers that lets a scanner find the QR code's position and orientation.
Error correction
Error correction is the use of extra encoded data to recover the message when part of the QR code is damaged or unreadable.
Mask pattern
A mask pattern is a rule that flips selected modules to avoid confusing visual patterns and make scanning more reliable.
Codeword
A codeword is a group of 8 bits used as a basic unit for storing QR data and error correction information.

Common Mistakes to Avoid

  • Thinking a QR code is just a picture. It is wrong because the picture follows strict grid, timing, format, data, and error correction rules.
  • Ignoring the quiet zone around the code. It is wrong because scanners need a clear blank border to separate the QR code from nearby text or graphics.
  • Assuming bigger always means more data. It is wrong because data capacity also depends on the QR version, encoding mode, and error correction level.
  • Covering finder patterns with a logo. It is wrong because the scanner may fail to locate or orient the QR code if the corner markers are blocked.

Practice Questions

  1. 1 A QR code has a 29 by 29 module grid. How many total modules does it contain?
  2. 2 A message uses 18 codewords, and each codeword is 8 bits. How many bits are used for the message before adding error correction?
  3. 3 Explain why increasing the error correction level can make a QR code more reliable but also reduce the amount of new information it can store.