QR Codes Explained: Complete Guide for Developers and Marketers
Everything you need to know about QR codes: how they work, what data types they support, design best practices, and common use cases for business and development.
What Are QR Codes?
QR codes (Quick Response codes) are two-dimensional barcodes that store information in a pattern of black and white squares. Invented in 1994 by Denso Wave for tracking automotive parts, they've become ubiquitous for sharing URLs, contact information, WiFi credentials, and more.
QR Code vs Traditional Barcode
| Feature | Traditional Barcode | QR Code |
|---|---|---|
| Dimensions | 1D (horizontal lines) | 2D (matrix) |
| Data Capacity | ~20 characters | ~4,296 characters |
| Data Types | Numbers only | Text, URLs, binary |
| Error Correction | None | Up to 30% recovery |
| Scan Angle | Must be horizontal | Any orientation |
Anatomy of a QR Code
Every QR code contains these essential elements:
- Finder Patterns: Three large squares in corners for orientation detection
- Alignment Patterns: Smaller squares that help scanners read distorted codes
- Timing Patterns: Alternating black/white lines between finder patterns
- Format Information: Error correction level and mask pattern
- Data Area: The actual encoded information
- Quiet Zone: White border around the code (minimum 4 modules)
How QR Codes Work
QR codes encode data using a specific process that converts text into a scannable pattern.
Encoding Process
- Data Analysis: Determine the most efficient encoding mode
- Data Encoding: Convert characters to binary
- Error Correction: Add Reed-Solomon error correction codes
- Structure: Arrange data in the matrix pattern
- Masking: Apply XOR mask for optimal scanning
- Format/Version: Add metadata for decoder
QR Code Versions
QR codes come in 40 versions, each with increasing capacity:
| Version | Size (modules) | Max Characters (L) |
|---|---|---|
| 1 | 21 x 21 | 25 alphanumeric |
| 10 | 57 x 57 | 395 alphanumeric |
| 20 | 97 x 97 | 1,249 alphanumeric |
| 40 | 177 x 177 | 4,296 alphanumeric |
Higher versions = more data but larger codes and slower scanning.
Encoding Modes
QR codes automatically select the most efficient mode:
- Numeric: Digits 0-9 (most efficient, ~3.3 bits per character)
- Alphanumeric: 0-9, A-Z, space, $%*+-./: (~5.5 bits per character)
- Byte: Any 8-bit data including UTF-8 (8 bits per character)
- Kanji: Japanese characters (13 bits per character)
// Same URL encoded differently based on content
"12345678901234" → Numeric mode (most compact)
"HTTPS://TOOLSDOCK.COM" → Alphanumeric mode
"https://toolsdock.com" → Byte mode (lowercase forces byte mode)Data Types and Encoding
QR codes support various data formats through standardized URI schemes.
URL (Most Common)
https://toolsdock.com/generators/codes/qr-code-generator/?utm_source=qrPlain Text
Any text content up to ~4,000 charactersWiFi Network
WIFI:T:WPA;S:NetworkName;P:Password123;H:false;;
Parameters:
T = Security type (WPA, WEP, nopass)
S = Network SSID
P = Password
H = Hidden network (true/false)vCard (Contact Information)
BEGIN:VCARD
VERSION:3.0
N:Doe;John
FN:John Doe
ORG:Company Name
TEL:+1-555-123-4567
EMAIL:hello@toolsdock.com
URL:https://toolsdock.com
END:VCARDmailto:hello@toolsdock.com?subject=Hello&body=Message%20herePhone Number
tel:+15551234567SMS
sms:+15551234567?body=Hello%20WorldCalendar Event
BEGIN:VEVENT
SUMMARY:Meeting Title
DTSTART:20240315T140000Z
DTEND:20240315T150000Z
LOCATION:Conference Room A
END:VEVENTGeo Location
geo:40.7128,-74.0060Bitcoin Payment
bitcoin:1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa?amount=0.001Error Correction Levels
QR codes use Reed-Solomon error correction to remain scannable even when partially damaged or obscured.
| Level | Recovery Capacity | Use Case |
|---|---|---|
| L (Low) | ~7% damage | Clean environments, maximum data |
| M (Medium) | ~15% damage | General purpose (default) |
| Q (Quartile) | ~25% damage | Industrial, outdoor use |
| H (High) | ~30% damage | Logos in center, harsh conditions |
Trade-offs
- Higher error correction = larger QR code for same data
- Higher error correction = slower scanning
- For clean digital displays, Level L is sufficient
- For printed materials that may get damaged, use Level M or higher
Design Best Practices
Size Guidelines
| Scan Distance | Minimum Size | Example Use |
|---|---|---|
| 10 cm (4") | 2 cm (0.8") | Business cards |
| 30 cm (12") | 3 cm (1.2") | Flyers, menus |
| 1 m (3 ft) | 10 cm (4") | Posters |
| 5 m (16 ft) | 50 cm (20") | Billboards |
Rule of thumb: QR code size should be 1/10th of the expected scan distance.
Contrast Requirements
- Dark foreground on light background works best
- Minimum contrast ratio: 4:1 (higher is better)
- Black on white has the best scan reliability
- Avoid red or orange foregrounds (hard for some scanners)
Good combinations:
- Black on white (best)
- Dark blue on white
- Black on light yellow
- Dark green on whiteAvoid:
- Light colors on light backgrounds
- Red on green (colorblind issues)
- Low contrast combinations
- Inverted (white on black) without testingAdding Logos
- Use error correction Level H
- Keep logo under 30% of QR code area
- Place logo exactly in center
- Add white padding around logo
- Test thoroughly with multiple devices
Quiet Zone
Always maintain a white border (quiet zone) around your QR code:
- Minimum: 4 modules wide
- Recommended: 10% of QR code size on each side
- Don't place text or graphics touching the QR code
File Format Recommendations
| Use Case | Format | Reason |
|---|---|---|
| Print (large) | SVG or PDF | Vector, scales infinitely |
| Print (fixed size) | PNG (300+ DPI) | Sharp edges, no compression artifacts |
| Web/Digital | PNG or SVG | Sharp, lossless |
| Documents | PNG | Universal compatibility |
Common Use Cases
Marketing and Advertising
- Print ads linking to landing pages
- Product packaging with extended information
- Event posters linking to ticket purchases
- Billboard campaigns with trackable URLs
Retail and Payments
- Mobile payment systems (Apple Pay, Google Pay)
- Product information and reviews
- Loyalty program enrollment
- Digital receipts
Authentication and Security
- Two-factor authentication (TOTP) setup
- Secure document verification
- Access control and ticketing
- Cryptocurrency wallet addresses
Information Sharing
- WiFi network credentials (hotels, cafes)
- Business cards and contact sharing
- Restaurant menus
- Museum exhibits and tours
Development and Testing
- App download links
- Deep links for mobile apps
- Debug URLs for testing
- Configuration data transfer
Healthcare
- Patient identification wristbands
- Medication information
- Vaccination certificates
- Medical record access
Generating QR Codes Programmatically
JavaScript (Browser)
// Using QRCode.js library
const qrcode = new QRCode(document.getElementById("qrcode"), {
text: "https://toolsdock.com",
width: 256,
height: 256,
colorDark: "#000000",
colorLight: "#ffffff",
correctLevel: QRCode.CorrectLevel.M
});Node.js
// Using qrcode package
const QRCode = require('qrcode');
// Generate as Data URL
const dataUrl = await QRCode.toDataURL('https://toolsdock.com');
// Generate as file
await QRCode.toFile('./qrcode.png', 'https://toolsdock.com', {
width: 300,
margin: 2,
errorCorrectionLevel: 'M'
});Python
# Using qrcode library
import qrcode
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_M,
box_size=10,
border=4,
)
qr.add_data('https://toolsdock.com')
qr.make(fit=True)
img = qr.make_image(fill_color="black", back_color="white")
img.save("qrcode.png")PHP
// Using phpqrcode library
include('phpqrcode/qrlib.php');
QRcode::png('https://toolsdock.com', 'qrcode.png', QR_ECLEVEL_M, 10, 2);Dynamic QR Codes
For trackable, editable QR codes, encode a short URL that redirects:
// Instead of encoding the full URL:
https://toolsdock.com/very/long/campaign/url?utm_source=print
// Encode a short redirect URL:
https://toolsdock.com/
// Benefits:
// - Smaller QR code (easier to scan)
// - Track scan analytics
// - Change destination without reprinting
// - A/B test different landing pagesTools and Resources
QR Code Generator
Create QR codes for URLs, text, WiFi, vCards, and more. Download as PNG or SVG.
Generate QR CodeBarcode Generator
Generate traditional 1D barcodes including Code 128, EAN-13, UPC-A, and more.
Generate BarcodeQuick Reference: QR Code Data Formats
| Type | Format |
|---|---|
| URL | https://toolsdock.com |
mailto:hello@toolsdock.com?subject=Hi | |
| Phone | tel:+15551234567 |
| SMS | sms:+15551234567?body=Hello |
| WiFi | WIFI:T:WPA;S:SSID;P:pass;; |
| Geo | geo:40.7128,-74.0060 |