PureTools

QR Codes: How They Work and How to Generate Them

PureTools Team· 5 min read
QR Codes: How They Work and How to Generate Them

QR Codes: More Than Just URLs

QR (Quick Response) codes can encode up to 4,296 alphanumeric characters in a scannable 2D pattern. They're used for URLs, WiFi passwords, payment info, contact cards, and authentication.

What Can a QR Code Contain?

TypeFormatExample
URLPlain URLhttps://example.com
WiFiWIFI:T:WPA;S:NetworkName;P:password;;Auto-connect to WiFi on scan
Emailmailto:user@example.comOpens email composer
Phonetel:+15551234567Initiates phone call
SMSsms:+15551234567?body=HelloOpens SMS with pre-filled text
vCardBEGIN:VCARD\nFN:John Doe\n...Adds contact to phone
TextPlain textAny text up to ~4000 chars

Error Correction Levels

QR codes can be partially damaged and still scan, thanks to Reed-Solomon error correction:

LevelRecoveryUse Case
L (Low)~7%Clean environments, maximum data capacity
M (Medium)~15%General use (default)
Q (Quartile)~25%Industrial, moderate damage expected
H (High)~30%Logo overlay — code works even with center covered

Generating QR Codes Programmatically

// Node.js
import QRCode from 'qrcode';

// Generate PNG
await QRCode.toFile('qr.png', 'https://example.com', {
  errorCorrectionLevel: 'M',
  width: 300,
});

// Generate SVG string
const svg = await QRCode.toString('https://example.com', {
  type: 'svg',
});
# Python
import qrcode

qr = qrcode.QRCode(error_correction=qrcode.constants.ERROR_CORRECT_M)
qr.add_data('https://example.com')
qr.make(fit=True)
img = qr.make_image()
img.save('qr.png')

WiFi QR Code Format

WIFI:T:WPA;S:MyNetwork;P:MyPassword;H:false;;

T = Authentication type (WPA, WEP, nopass)
S = SSID (network name)
P = Password
H = Hidden network (true/false)

Print this QR code and guests can join your WiFi by scanning — no typing passwords.

Generate QR codes: QR Code Generator — create QR codes for URLs, text, and more. Also try WiFi QR Code for sharing WiFi passwords.