What is a QR code?
A QR code (Quick Response code) is a two-dimensional barcode that stores data as a matrix of black and white squares. Unlike a standard 1D barcode that encodes data in a single row, a QR code encodes data both horizontally and vertically, allowing it to hold significantly more information in a small physical space.
QR codes were invented in 1994 by Masahiro Hara at Denso Wave, a subsidiary of Toyota, originally for tracking automotive parts during manufacturing. The technology was made patent-free in 1999, which is a major reason for its widespread adoption. Since smartphone cameras gained native QR scanning capabilities around 2017–2018, usage has exploded — particularly for payments, menus, and contactless information sharing.
Anatomy of a QR code
Every QR code contains several distinct regions:
- Finder patterns — the three large squares in the corners (not the fourth). These allow scanners to detect the code's position and orientation from any angle.
- Alignment patterns — smaller squares that help correct for distortion when the code is printed on a curved or bent surface.
- Timing patterns — alternating black and white modules that help determine the size of individual cells.
- Format information — strips beside the finder patterns that encode error correction level and masking pattern.
- Data modules — the remaining cells that encode the actual payload.
- Quiet zone — the mandatory white border around the entire code (at least 4 modules wide). Scanners require this empty zone to locate the code boundary.
Data types a QR code can encode
QR codes support several encoding modes, each optimised for a different character set:
- Numeric — digits 0–9 only, most compact mode (3.33 bits per character)
- Alphanumeric — digits, uppercase letters, and a handful of symbols. Used for short URLs in uppercase form.
- Binary / byte — any UTF-8 text, including lowercase letters, punctuation, and Unicode characters. Used for URLs, emails, and free text.
- Kanji — double-byte characters for Japanese text.
Practically, the mode is chosen automatically by the generator based on the input. For typical URLs and text, the binary mode is 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 read even if part of it is damaged, dirty, or obscured. There are four levels:
- L (Low) — recovers up to 7% of damaged data. Smallest code, least redundancy. Use when the code will be displayed on screen in good conditions.
- M (Medium) — recovers up to 15%. Good default for general use.
- Q (Quartile) — recovers up to 25%. Good for industrial environments or codes printed on textured surfaces.
- H (High) — recovers up to 30%. Best for codes that may get dirty, scratched, or partially covered. Required if you want to add a logo in the centre of the QR code.
Higher error correction = larger QR code (more redundant data modules are needed). For a URL displayed on a website, Level M is usually the right balance. For a code printed on outdoor signage or packaging, use Level H.
How much data can a QR code hold?
A QR code's capacity depends on its version (size) and error correction level. The maximum capacities at error correction Level L are:
- Numeric: up to 7,089 digits
- Alphanumeric: up to 4,296 characters
- Binary: up to 2,953 bytes
In practice, shorter payloads produce smaller, faster-scanning codes. A long URL with many parameters creates a dense code that is slower to scan and more prone to read errors. Where possible, use a URL shortener before encoding.
Common QR code use cases
- URLs — the most common use. Link to a website, landing page, or product page.
- WiFi credentials — encode SSID and password so guests scan to join without typing. Format:
WIFI:T:WPA;S:NetworkName;P:Password;; - Contact cards (vCard) — encode a full vCard so the recipient can save your contact in one scan.
- Payments — UPI, PayPal, and bank payment links encoded as QR codes for point-of-sale transactions.
- App store links — direct link to an iOS or Android app.
- Authentication — used in two-factor authentication apps (TOTP secret encoded in a QR code).
- Event tickets and boarding passes — a unique URL or ticket ID encoded for scanning at the gate.
Tips for generating a good QR code
- Keep the payload short — shorter URLs produce less dense, faster-scanning codes.
- Choose the right error correction — use H if adding a logo or if the code will be printed in rough conditions.
- Maintain the quiet zone — do not let other design elements touch the border of the code.
- Test before printing — always scan the generated code with at least two different devices before sending to print.
- Minimum print size — a QR code should be at least 2 cm × 2 cm for reliable scanning at a normal reading distance.
- High contrast — stick to black modules on a white background. Avoid low-contrast colour combinations and gradients.