What Are QR Codes?

A QR code (Quick Response code) is a two-dimensional matrix barcode invented in 1994 by Denso Wave, a subsidiary of Toyota. Originally designed to track automotive parts on assembly lines, QR codes have become one of the most widely used data-encoding formats in the world. You encounter them on restaurant menus, event tickets, payment terminals, product packaging, and billboard advertisements.

Unlike traditional one-dimensional barcodes that store data in a single row of varying-width lines, QR codes store data in a grid of black and white squares called modules. This two-dimensional layout allows QR codes to encode dramatically more information — up to 7,089 numeric characters or 2,953 bytes of binary data — in a compact square that can be scanned from any angle.

QR codes can encode many types of data: URLs, plain text, contact information (vCards), Wi-Fi network credentials, email addresses, phone numbers, geographic coordinates, and calendar events. When you scan a QR code with your phone's camera, the device reads the encoded data and takes the appropriate action — opening a website, joining a Wi-Fi network, or adding a contact.

How QR Codes Encode Data

QR codes support four encoding modes, each optimized for a different type of data. The encoder automatically selects the most efficient mode (or mixes modes within a single QR code) to minimize the number of modules needed:

The data capacity varies significantly by mode. Here is a comparison for a Version 10 QR code (57 x 57 modules) at each error correction level:

Error Correction Numeric Alphanumeric Binary (bytes) Kanji
L (7%) 652 395 271 167
M (15%) 513 311 213 131
Q (25%) 364 221 151 93
H (30%) 288 174 119 74

Beyond the data payload, every QR code contains several structural elements that enable scanning. Three finder patterns — the large squares in three corners — allow the scanner to locate and orient the code regardless of rotation. Alignment patterns (smaller squares) help correct for perspective distortion on larger codes. Timing patterns (alternating black and white modules in rows and columns) establish the grid spacing. A format information strip encodes the error correction level and mask pattern used.

Error Correction Levels

One of the most important features of QR codes is built-in error correction using Reed-Solomon codes. This means a QR code can still be decoded even if part of it is damaged, dirty, or obscured. The QR standard defines four error correction levels:

The tradeoff is straightforward: higher error correction means more redundant data, which means more modules, which means a larger QR code. For the same data payload, a QR code at level H can be up to 1.5 times wider than one at level L because it needs a higher-version code to fit all the error correction codewords.

// Error correction overhead comparison
// Encoding "https://toolplex.dev" (20 characters, binary mode)

Level L → Version 2 (25×25 modules) — 160 bits of data capacity
Level M → Version 2 (25×25 modules) — 128 bits of data capacity
Level Q → Version 3 (29×29 modules) — 104 bits of data capacity
Level H → Version 3 (29×29 modules) — 72 bits of data capacity

// Same data, but H-level needs a larger version to fit it

Reed-Solomon error correction works by treating the data as a polynomial over a finite field (Galois field GF(28)) and generating error correction codewords that can locate and fix errors. The mathematics is the same used in CD/DVD error correction and digital television broadcasting. For QR codes, the data is divided into blocks, and each block gets its own set of error correction codewords. This block structure means that burst damage (like a scratch across one area) is less likely to destroy an entire block.

QR Code Versions and Size

QR codes come in 40 versions, numbered 1 through 40. Each version increase adds 4 modules to each side of the grid:

The general formula is: a Version V QR code has (4V + 17) modules per side. Version 1 has 4(1) + 17 = 21 modules; Version 40 has 4(40) + 17 = 177 modules.

In practice, you should aim for the lowest version that fits your data at your chosen error correction level. Lower versions produce simpler codes with larger individual modules, which are easier to scan at a distance and more tolerant of printing imperfections. Most URL-based QR codes fall in the Version 2 to Version 6 range.

Versions 7 and above include version information — a small encoded block near the finder patterns that tells the scanner which version the code is. Versions 2 and above include alignment patterns to help correct for perspective distortion, with more alignment patterns added as the version increases.

Design Best Practices

A QR code that looks perfect on your screen can fail completely in the real world if you ignore a few critical design rules. Here are the most important ones:

// Quick checklist for QR code design
✓ Quiet zone: 4+ module margin on all sides
✓ Module size: ≥ 0.33 mm per module
✓ Total size: ≥ 2 cm for close-range scanning
✓ Contrast ratio: dark on light (not inverted)
✓ Shape: perfectly square, no distortion
✓ Error correction: M for standard, H for logos
✓ Test: scan with at least 3 different devices

Embedding Logos in QR Codes

One of the most common QR code customizations is placing a logo or icon in the center. This is possible because of error correction — the logo covers and destroys some modules, but the Reed-Solomon algorithm recovers the lost data from the redundant codewords.

To embed a logo safely, follow these rules:

Keep in mind that adding a logo increases the effective version of the QR code. The data payload stays the same, but the error correction level must increase from M to H, which requires more codewords. For a short URL, this might bump you from a Version 2 code (25 x 25) to a Version 4 code (33 x 33) — a noticeable size increase.

QR Code Use Cases

QR codes are versatile enough to encode many types of structured data. Here are the most common use cases and the data format each one uses:

// Common QR code data formats

// URL
https://toolplex.dev/qr-code-generator/

// Wi-Fi credentials
WIFI:T:WPA;S:MyNetwork;P:MyPassword123;;

// vCard contact
BEGIN:VCARD
VERSION:3.0
N:Doe;John
FN:John Doe
TEL:+1-555-123-4567
EMAIL:[email protected]
END:VCARD

// Calendar event
BEGIN:VEVENT
SUMMARY:Team Meeting
DTSTART:20260401T100000Z
DTEND:20260401T110000Z
LOCATION:Conference Room B
END:VEVENT

When choosing a use case, keep data length in mind. A URL like https://example.com is 19 characters and produces a small, easily scannable Version 2 QR code. A full vCard with address and organization details might be 300+ characters, requiring a Version 8 or higher code with densely packed modules that are harder to scan from a distance.