100% Private

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

FeatureTraditional BarcodeQR Code
Dimensions1D (horizontal lines)2D (matrix)
Data Capacity~20 characters~4,296 characters
Data TypesNumbers onlyText, URLs, binary
Error CorrectionNoneUp to 30% recovery
Scan AngleMust be horizontalAny 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

  1. Data Analysis: Determine the most efficient encoding mode
  2. Data Encoding: Convert characters to binary
  3. Error Correction: Add Reed-Solomon error correction codes
  4. Structure: Arrange data in the matrix pattern
  5. Masking: Apply XOR mask for optimal scanning
  6. Format/Version: Add metadata for decoder

QR Code Versions

QR codes come in 40 versions, each with increasing capacity:

VersionSize (modules)Max Characters (L)
121 x 2125 alphanumeric
1057 x 57395 alphanumeric
2097 x 971,249 alphanumeric
40177 x 1774,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=qr

Plain Text

Any text content up to ~4,000 characters

WiFi 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:VCARD

Email

mailto:hello@toolsdock.com?subject=Hello&body=Message%20here

Phone Number

tel:+15551234567

SMS

sms:+15551234567?body=Hello%20World

Calendar Event

BEGIN:VEVENT
SUMMARY:Meeting Title
DTSTART:20240315T140000Z
DTEND:20240315T150000Z
LOCATION:Conference Room A
END:VEVENT

Geo Location

geo:40.7128,-74.0060

Bitcoin Payment

bitcoin:1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa?amount=0.001

Error Correction Levels

QR codes use Reed-Solomon error correction to remain scannable even when partially damaged or obscured.

LevelRecovery CapacityUse Case
L (Low)~7% damageClean environments, maximum data
M (Medium)~15% damageGeneral purpose (default)
Q (Quartile)~25% damageIndustrial, outdoor use
H (High)~30% damageLogos in center, harsh conditions
Pro Tip: Use Level H if you plan to add a logo in the center of your QR code. The high error correction compensates for the obscured data modules.

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 DistanceMinimum SizeExample 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 white
Avoid:
- Light colors on light backgrounds
- Red on green (colorblind issues)
- Low contrast combinations
- Inverted (white on black) without testing

Adding Logos

  1. Use error correction Level H
  2. Keep logo under 30% of QR code area
  3. Place logo exactly in center
  4. Add white padding around logo
  5. 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 CaseFormatReason
Print (large)SVG or PDFVector, scales infinitely
Print (fixed size)PNG (300+ DPI)Sharp edges, no compression artifacts
Web/DigitalPNG or SVGSharp, lossless
DocumentsPNGUniversal compatibility
Never use JPEG for QR codes. Compression artifacts can make codes unscannable.

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 pages

Tools and Resources

QR Code Generator

Create QR codes for URLs, text, WiFi, vCards, and more. Download as PNG or SVG.

Generate QR Code
Barcode Generator

Generate traditional 1D barcodes including Code 128, EAN-13, UPC-A, and more.

Generate Barcode
URL Encoder

Properly encode URLs before embedding in QR codes.

Encode URL
SVG to PNG Converter

Convert vector QR codes to high-resolution PNG for printing.

Convert SVG

Quick Reference: QR Code Data Formats

TypeFormat
URLhttps://toolsdock.com
Emailmailto:hello@toolsdock.com?subject=Hi
Phonetel:+15551234567
SMSsms:+15551234567?body=Hello
WiFiWIFI:T:WPA;S:SSID;P:pass;;
Geogeo:40.7128,-74.0060

Last updated: December 2024

All QR code generation on ToolsDock happens in your browser. No data is sent to any server.

Privacy Notice: This site works entirely in your browser. We don't collect or store your data. Optional analytics help us improve the site. You can deny without affecting functionality.