QR codes have evolved from a niche automotive tracking tool to an essential part of modern digital life. From restaurant menus to payment systems, WiFi sharing to event tickets — QR codes are everywhere. As a developer, understanding how to generate and work with QR codes is a valuable skill.
This guide covers everything you need to know: how QR codes work, the different types, and how to generate them in your applications.
🔲 What Is a QR Code?
QR stands for Quick Response. It's a two-dimensional barcode that stores information in a grid of black and white squares. Unlike traditional barcodes (which store data horizontally), QR codes store data in both directions — allowing them to hold much more information.
QR Code Capacity
- Numeric only: 7,089 characters
- Alphanumeric: 4,296 characters
- Binary (8-bit): 2,953 bytes
- Kanji/Kana: 1,817 characters
📋 Types of QR Codes
QR codes can encode different types of data using specific formats. Here are the most common ones:
🌐 URL
Opens a website
https://example.com
Sends an email
mailto:user@mail.com
📞 Phone
Dials a number
tel:+1234567890
📶 WiFi
Connects to network
WIFI:T:WPA;S:Name;P:Pass;;
👤 vCard
Saves contact info
BEGIN:VCARD...
📍 Location
Opens map
geo:37.7,-122.4
⚡ Generate QR Codes Instantly
Create QR codes for URLs, WiFi, email, phone, and more — right in your browser.
Open QR Code Generator →🔧 WiFi QR Code Format
One of the most useful QR code types for businesses and homes is the WiFi QR code. When scanned, it automatically connects the device to the network.
Format
WIFI:T:<authentication>:<SSID>P:<password>;
Parameters
T— Authentication type:WPA,WEP, ornopassS— Network name (SSID)P— Password (omit if no authentication)
Example
WIFI:T:WPA;S:MyHomeNetwork;P:SecretPassword123;;
👤 vCard QR Code Format
vCard QR codes encode contact information that can be saved directly to the phone's address book.
BEGIN:VCARD
VERSION:3.0
FN:John Doe
TEL:+1234567890
EMAIL:john@example.com
ORG:Acme Inc
TITLE:Software Engineer
URL:https://johndoe.com
END:VCARD
💻 Generating QR Codes Programmatically
JavaScript (using qrcode.js)
// Install: npm install qrcode
import QRCode from 'qrcode';
// Generate PNG data URL
const url = await QRCode.toDataURL('https://example.com');
// Generate to canvas
const canvas = document.getElementById('canvas');
await QRCode.toCanvas(canvas, 'https://example.com');
Python (using qrcode library)
# Install: pip install qrcode[pil]
import qrcode
qr = qrcode.QRCode(version=1, box_size=10, border=5)
qr.add_data('https://example.com')
qr.make(fit=True)
img = qr.make_image(fill_color="black", back_color="white")
img.save('qrcode.png')
Go
// go get github.com/skip2/go-qrcode
import "github.com/skip2/go-qrcode"
qr, _ := qrcode.New("https://example.com", qrcode.Medium)
png, _ := qr.PNG(256)
// Write png bytes to file
🎨 QR Code Design Tips
- Quiet zone: Leave at least 4 modules of white space around the QR code
- Contrast: Use dark modules on light background for best scanning
- Logo placement: Center logo can cover up to 30% (with high error correction)
- Error correction levels:
- L: 7% recovery (most capacity)
- M: 15% recovery
- Q: 25% recovery
- H: 30% recovery (best for logos)
📱 Real-World Use Cases
| Use Case | QR Type | Example |
|---|---|---|
| Restaurant menus | URL | Link to online menu |
| WiFi sharing | WiFi | Guest network access |
| Business cards | vCard | Contact information |
| Payments | URL/App | Payment app deep link |
| Event tickets | Text/URL | Ticket verification |
| Product tracking | Text | Serial numbers |
✅ Best Practices
- Keep it simple: Shorter content = larger modules = easier scanning
- Test thoroughly: Scan with multiple devices and apps
- Provide context: Tell users what the QR code does
- Use URL shorteners: For URLs, shorter = better QR code
- Consider error correction: Use H level for printed materials
- Include a fallback: Show the URL/text below the QR code
🔗 Conclusion
QR codes are a simple yet powerful tool for bridging the physical and digital worlds. Whether you're building a contactless menu system, sharing WiFi credentials, or creating a marketing campaign, QR codes provide an elegant solution.
With modern libraries and tools, generating QR codes is easier than ever. Start experimenting with different types and use cases — and remember to always test before deploying!