What's Inside a QR Code? Modules, Error Correction, and How Scanners Read Them

posted 4 min read

You scan QR codes every day, but have you ever looked at one and wondered what the individual squares actually mean? QR codes look like random noise, but every element has a defined purpose. Understanding the structure helps you make smarter choices when generating or embedding them.

The Grid: Modules and Version

A QR code is a square grid of black and white cells. Each cell is called a module — not a pixel, because the physical size varies by medium.

The grid size depends on the version number, which runs from 1 to 40:

  • Version 1: 21×21 modules (smallest)
  • Version 40: 177×177 modules (largest)
  • Each version step adds 4 modules per side

The version you need depends on how much data you are encoding. A URL under 25 characters fits in Version 1. A full paragraph of text might need Version 15 or higher.

The Fixed Patterns

Before any data is encoded, several fixed patterns are placed in the grid. These are the same in every QR code at every version and allow scanners to orient and decode the code.

Finder Patterns — three identical square targets, one in each corner except the bottom-right. They look like a small square inside a larger square with a white border. Scanners locate these first to establish the QR code's position, size, and orientation. They work even if the code is rotated or viewed at an angle.

Separator Lines — a one-module white border around each finder pattern, separating them from the data area.

Timing Patterns — alternating black/white stripes running horizontally and vertically between the top-left and top-right finder patterns. They tell the scanner exactly how large each module is and where grid lines fall.

Alignment Patterns — small square targets (5×5 modules) that appear in Version 2 and above, more of them at higher versions. They help scanners correct for perspective distortion when the code is photographed at an angle or printed on a curved surface.

Dark Module — a single always-black module at a fixed position. It is part of the format information and is always present.

Format Information

Two strips of 15 modules each (mirrored near each finder pattern) encode:

  • The error correction level (L, M, Q, or H)
  • The mask pattern (which data modules were inverted)

This information is read before any data decoding can happen.

Error Correction

QR codes use Reed-Solomon error correction. This is the same algorithm used in CDs, DVDs, and QR codes to recover data even when parts of the code are damaged, obscured, or dirty.

There are four levels:

  • L (Low): recovers up to 7% damaged modules
  • M (Medium): recovers up to 15%
  • Q (Quartile): recovers up to 25%
  • H (High): recovers up to 30%

Higher error correction means more of the code is devoted to redundancy data rather than your actual content, so you need a larger version (bigger grid) to hold the same payload. This is why QR codes with logos cut out of the centre still scan — the missing modules are recovered by error correction. You can cut out up to 30% of the centre at Level H.

For most use cases (links, contact cards), Level M is a good default balance between size and resilience. Use Level H if the code will be printed on a surface that gets worn.

The Data Encoding

The actual payload — your URL, text, or phone number — is stored in the remaining modules after all the fixed patterns are placed. The data is encoded in a specific mode:

  • Numeric mode: only digits 0–9, most efficient for phone numbers
  • Alphanumeric mode: digits, uppercase A–Z, and a few special characters
  • Byte mode: any byte sequence (UTF-8 text, URLs with mixed case and special chars)
  • Kanji mode: compact encoding for Japanese characters

Most URLs use byte mode. The encoder adds a mode indicator, a character count, the encoded data, and then Reed-Solomon error correction codewords — all packed into the data modules in a specific serpentine path through the grid.

Mask Patterns

After encoding, the data modules are XOR'd with one of eight predefined mask patterns. The purpose: avoid long runs of the same colour, which could confuse scanners into misreading the timing patterns. The encoder tries all 8 masks and picks the one that gives the most balanced black/white distribution.

Generating a QR Code

For URLs and basic text, the structure above is handled automatically by any QR code library. If you want to generate one quickly without installing anything, the SnappyTools QR Code Generator produces downloadable PNG QR codes entirely in your browser — no upload, no account.

Choose your error correction level based on where the code will appear: L/M for screen display, Q/H for print or physical surfaces.

Summary

  • QR codes are grids of modules; size (version) grows with data volume
  • Fixed finder, timing, and alignment patterns let scanners orient the code from any angle
  • Reed-Solomon error correction lets codes survive up to 30% damage (Level H)
  • The data payload is encoded in one of four modes and masked to ensure balanced module distribution
  • Higher error correction = more redundancy = larger code for the same payload

Originally published at https://snappytools.app/qr-code-generator/

More Posts

I’m a Senior Dev and I’ve Forgotten How to Think Without a Prompt

Karol Modelskiverified - Mar 19

TypeScript Complexity Has Finally Reached the Point of Total Absurdity

Karol Modelskiverified - Apr 23

How I Built a React Portfolio in 7 Days That Landed ₹1.2L in Freelance Work

Dharanidharan - Feb 9

Sovereign Intelligence: The Complete 25,000 Word Blueprint (Download)

Pocket Portfolioverified - Apr 1

Just completed another large-scale WordPress migration — and the client left this

saqib_devmorph - Apr 7
chevron_left

Related Jobs

View all jobs →

Commenters (This Week)

1 comment
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!