QR codes are everywhere — on restaurant menus, product packaging, business cards, event tickets, and transit passes. What started as a tracking tool for automotive parts in 1994 has become one of the most versatile data-encoding technologies in everyday life. But how do those little black-and-white squares actually work? And what should you know to generate effective QR codes for your own projects?
This guide breaks down the anatomy of a QR code, explains the clever error correction system that makes them so resilient, covers the most common data types you can encode, and walks through best practices for creating QR codes that scan reliably every time.
The Anatomy of a QR Code
QR stands for Quick Response. Unlike traditional one-dimensional barcodes that store data in a single row of varying-width lines, QR codes are two-dimensional — they encode data in both horizontal and vertical directions across a grid of black and white modules (squares).
Every QR code contains several structural elements that scanners use to locate and decode the data:
- Finder patterns — The three large squares in the top-left, top-right, and bottom-left corners. These allow a scanner to identify the QR code's position, orientation, and angle regardless of how the code is rotated.
- Alignment patterns — Smaller squares placed throughout larger QR codes (version 2 and above) that help the scanner compensate for distortion, such as when scanning from an angle or on a curved surface.
- Timing patterns — Alternating black-and-white modules running between the finder patterns. These establish the grid coordinates so the scanner knows exactly where each data module falls.
- Format information — Encoded near the finder patterns, this tells the scanner which error correction level and mask pattern the code uses.
- Data and error correction modules — The remaining area contains the actual encoded data interleaved with Reed-Solomon error correction codewords.
QR Code Versions and Data Capacity
QR codes come in 40 different versions, where version 1 is a 21×21 module grid and each subsequent version adds 4 modules per side. Version 40, the largest, is a 177×177 grid. The version determines the maximum amount of data the code can hold.
The data capacity also depends on the type of content and the error correction level selected. Here are the approximate maximums for Version 40 at the lowest error correction level (L):
- Numeric only (0–9): up to 7,089 characters
- Alphanumeric (0–9, A–Z, space, $%*+-./:): up to 4,296 characters
- Binary/byte (UTF-8): up to 2,953 bytes
- Kanji: up to 1,817 characters
In practice, most QR codes you encounter are between version 2 and version 10. A typical URL of 50–100 characters fits comfortably in a small, easy-to-scan code. The key principle: shorter data produces simpler codes that scan faster and more reliably.
Error Correction: Why Damaged QR Codes Still Work
One of the most impressive features of QR codes is their built-in error correction, which uses Reed-Solomon error correction codes. This means a QR code can be partially obscured, damaged, or dirty and still scan correctly. The QR specification defines four error correction levels:
- Level L (Low) — Recovers up to ~7% of data. Produces the smallest code for a given data payload.
- Level M (Medium) — Recovers up to ~15%. The default for most generators and a good balance between size and resilience.
- Level Q (Quartile) — Recovers up to ~25%. Useful when codes will be printed on rough surfaces or partially covered.
- Level H (High) — Recovers up to ~30%. Required if you want to place a logo or image in the center of the QR code — the logo effectively "damages" that area, and Level H ensures the data can still be recovered.
Higher error correction means more redundant data modules, which increases the code size for the same payload. Choose the level based on your use case — Level M is fine for screen displays, while Level Q or H is better for printed materials exposed to wear.
Common QR Code Data Types
While a QR code can encode any arbitrary string, certain data formats trigger specific actions on the scanning device. Here are the most widely used types:
URLs
The most common use case. Encoding a URL like https://example.com/page causes the scanner to open the link in a browser. Use a URL shortener if the original URL is very long — this keeps the QR code simpler and easier to scan.
vCards (Contact Information)
A vCard-formatted string lets someone scan the code and instantly save your contact information. The format looks like this:
BEGIN:VCARD
VERSION:3.0
N:Chen;Alice
FN:Alice Chen
ORG:TensorLocal
TEL:+1-555-0123
EMAIL:[email protected]
URL:https://tensorlocal.com
END:VCARD
Wi-Fi Network Credentials
Encode your Wi-Fi network details so guests can connect by scanning the code instead of typing a password:
WIFI:T:WPA;S:MyNetworkName;P:MySecretPassword;;
The T parameter specifies the authentication type (WPA, WEP, or nopass), S is the SSID, and P is the password. Android and iOS both natively support this format.
Other Formats
- Email:
mailto:[email protected]?subject=Hello - SMS:
smsto:+15550123:Your message here - Geo location:
geo:37.7749,-122.4194 - Calendar event: Using the iCalendar (VEVENT) format
- Plain text: Any arbitrary text displayed on screen
Best Practices for QR Code Design
Generating a QR code is trivial. Generating one that works reliably in the real world requires attention to a few important details:
1. Maintain Sufficient Contrast
QR scanners rely on contrast between the dark and light modules. Dark modules on a light background is the standard and works best. Avoid low-contrast color combinations like light gray on white, or yellow on orange. If you must use colors, ensure the dark modules are at least 40% darker than the background when converted to grayscale.
2. Include a Quiet Zone
The quiet zone is the blank margin around the QR code. The specification requires a minimum of 4 modules of whitespace on all sides. Without this margin, nearby text, borders, or graphics can confuse the scanner and prevent successful decoding.
3. Size Appropriately
A general rule: the QR code should be at least 2 cm × 2 cm (about 0.8 inches) for close-up scanning (menus, business cards). For posters or signage scanned from a distance, the code should be roughly 1/10th of the expected scanning distance. A code scanned from 1 meter away should be at least 10 cm wide.
4. Test Before Deploying
Always test your QR code with multiple devices and scanning apps before printing. Test on both iOS and Android, in various lighting conditions, and from different angles. A code that works on your phone might fail on an older device with a lower-resolution camera.
5. Use Dynamic QR Codes When Possible
A static QR code encodes data directly — if you need to change the destination URL, you must generate and reprint a new code. A dynamic QR code encodes a short redirect URL that you can update at any time. This is essential for printed materials where reprinting is expensive or impractical.
Generate custom QR codes instantly — for URLs, Wi-Fi, vCards, and more. Free and private.
Open QR Code Generator →QR Codes vs. Other 2D Barcodes
QR codes are not the only two-dimensional barcode format, but they are the most widely adopted for consumer-facing use cases. Here is how they compare to the main alternatives:
- Data Matrix — Common in industrial and healthcare settings. More compact than QR for small amounts of data but lacks the finder patterns that make QR codes so fast to locate and scan casually.
- PDF417 — A stacked linear barcode used on boarding passes, driver's licenses, and shipping labels. Can hold more data than a QR code but requires a more precise scanning alignment.
- Aztec Code — Used primarily in transport ticketing (airline boarding passes, European rail tickets). Does not require a quiet zone, which makes it compact, but has less widespread scanner support in general-purpose apps.
For most web and marketing applications, QR codes remain the clear winner due to universal scanner support on smartphones and a well-established ecosystem of generation and management tools.
Conclusion
QR codes are a deceptively sophisticated technology. Behind every small grid of black-and-white squares is a carefully engineered system of positioning markers, timing patterns, and Reed-Solomon error correction that makes scanning fast, reliable, and resilient to damage. Understanding how they work helps you make better decisions about error correction levels, data formats, sizing, and design — all of which directly impact whether your QR code gets scanned or ignored.
Ready to create your own? Our QR Code Generator lets you encode URLs, Wi-Fi credentials, contact cards, and plain text with full control over size and error correction — all processed locally in your browser with nothing uploaded to a server.