Back to Blog Index
Developer Workflows11 min read

QR Code Technology: How They Work, Best Practices for Generation, and Security Considerations

Understand the engineering behind QR code encoding, error correction levels, data capacity limits, and security considerations for generating trustworthy QR codes.

ToolZeno Editorial Team

Software Architecture & Security Guild

Published 2026-07-08 (Updated 2026-07-30)
#QR Code#Barcode#Encoding#Mobile#WiFi#vCard

How QR Codes Work: Structure and Encoding

QR (Quick Response) codes are two-dimensional matrix barcodes invented by Denso Wave in 1994 for tracking automotive parts. Unlike traditional one-dimensional barcodes that encode data in a single row of varying-width bars, QR codes use a grid of black and white modules (squares) to encode data in both horizontal and vertical dimensions, dramatically increasing data capacity.

Every QR code contains several structural elements that enable reliable scanning. The three large square patterns in the corners (finder patterns) allow scanners to detect the QR code's position and orientation from any angle. Timing patterns (alternating black and white modules) between the finder patterns establish the grid spacing. Alignment patterns (smaller squares) help scanners correct for perspective distortion when the code is photographed at an angle.

The data area contains the encoded payload in one of four modes — Numeric (digits only, most efficient), Alphanumeric (uppercase letters, digits, and some symbols), Byte (arbitrary binary data including UTF-8 text), and Kanji (Japanese characters). The mode is selected automatically based on the input content, with the encoder choosing the most space-efficient mode that can represent the data.

QR codes range from Version 1 (21x21 modules, up to 25 alphanumeric characters) to Version 40 (177x177 modules, up to 4,296 alphanumeric characters). Higher versions create denser, larger codes that require higher-resolution cameras to scan reliably.

Data Capacity Limits

A Version 40 QR code with Low error correction can store up to 7,089 numeric characters, 4,296 alphanumeric characters, or 2,953 bytes of binary data. For practical use, keep payloads under 300 characters for reliable scanning.

Error Correction Levels and Reliability Engineering

One of QR codes' most powerful features is Reed-Solomon error correction, which allows partial data recovery even when the code is damaged, dirty, or partially obscured. QR codes support four error correction levels, each trading data capacity for reliability.

Level L (Low) recovers approximately 7% of damaged data. This provides maximum data capacity and is suitable for clean, controlled environments like digital screens and printed materials that won't be damaged.

Level M (Medium) recovers approximately 15% of damaged data. This is the default level for most use cases, balancing capacity with reasonable tolerance for minor scratches, smudges, or wear.

Level Q (Quartile) recovers approximately 25% of damaged data. This is recommended for QR codes printed on product packaging, outdoor signage, or materials that may experience moderate physical wear.

Level H (High) recovers approximately 30% of damaged data. This maximum correction level is required when logos or images are placed over the QR code centre (a common branding technique) because the logo effectively "damages" the underlying modules. It is also essential for QR codes exposed to harsh environments — factory floors, outdoor installations, or codes that may be partially covered.

The choice of error correction level directly impacts the QR code's physical size and minimum scanning resolution. Higher correction levels add more redundancy data, requiring more modules and thus a larger physical code or a denser grid for the same payload.

  • Use Level M (Medium, 15% recovery) as the default for standard web and print QR codes.
  • Use Level H (High, 30% recovery) when embedding logos in the QR code centre.
  • Keep payloads short — shorter data produces simpler codes that scan faster and more reliably.
  • Test QR codes on multiple devices and at various distances before deploying to production.

Practical QR Code Applications: WiFi, vCard, and URL Encoding

Beyond simple URL encoding, QR codes support standardised payload formats for specific use cases that trigger native device actions when scanned.

WiFi Network Sharing — The WIFI: URI scheme encodes network credentials in the format WIFI:T:WPA;S:NetworkName;P:Password;H:false;; where T is the security type (WPA, WEP, or nopass), S is the SSID, P is the password, and H indicates whether the network is hidden. When scanned, modern smartphones automatically prompt the user to join the network without manual credential entry. This is invaluable for guest networks, hotel rooms, co-working spaces, and events.

vCard Contact Sharing — The vCard format (BEGIN:VCARD ... END:VCARD) encodes structured contact information including name, phone numbers, email addresses, organisation, title, and physical address. Scanning a vCard QR code prompts the user's phone to add the contact directly to their address book. This is widely used on business cards, conference badges, and networking events.

URL Encoding — The simplest and most common QR code payload is a URL. When scanned, the device opens the URL in the default browser. Best practices include using HTTPS URLs, keeping URLs short (use URL shorteners if necessary to reduce QR code complexity), and including UTM parameters for marketing attribution tracking.

Plain Text and Email — QR codes can encode plain text messages or mailto: URIs that pre-compose emails with subject lines and body text. These are useful for feedback forms, support contact shortcuts, and automated reporting workflows.

QR Code Security: Phishing, Quishing, and Safe Scanning

The widespread adoption of QR codes has introduced new security attack vectors collectively known as "quishing" (QR phishing). Malicious actors replace legitimate QR codes on parking meters, restaurant menus, package delivery notices, and public signage with codes that redirect to phishing websites, malware downloads, or credential-harvesting pages.

The fundamental security challenge is that humans cannot visually inspect a QR code to determine its destination — unlike a visible hyperlink where you can read the domain name before clicking, a QR code's payload is opaque until scanned and decoded.

For QR code generators, security best practices include clearly displaying the encoded URL or data next to the generated QR code so users can verify the destination, using HTTPS URLs exclusively to prevent man-in-the-middle interception, and avoiding URL shorteners in security-sensitive contexts (like banking or authentication) because they obscure the final destination.

For QR code consumers, best practices include using a scanner that previews the decoded content before navigating to URLs (most modern smartphone cameras do this), being suspicious of QR codes placed as stickers over existing codes (a common replacement attack technique), and never scanning QR codes from unsolicited sources like random flyers, unexpected package labels, or unfamiliar emails.

ToolZeno's QR Code Generator and Scanner tools run entirely client-side, meaning the generated codes and scanned data never leave your browser. This prevents the privacy risk of external QR services potentially logging your encoded URLs, WiFi passwords, or contact information.

Frequently Asked Questions

Q:What is the maximum amount of data a QR code can store?

A Version 40 QR code with Low error correction can store up to 7,089 numeric characters, 4,296 alphanumeric characters, or 2,953 bytes of binary data. However, for reliable scanning, it is recommended to keep payloads under 300 characters.

Q:Can I put a logo in the centre of a QR code?

Yes, but you must use High (H) error correction level, which provides 30% data recovery. The logo effectively damages the central modules, and the error correction compensates. Keep the logo under 30% of the QR code area.

Q:What is quishing and how can I protect against it?

Quishing (QR phishing) involves replacing legitimate QR codes with malicious ones that redirect to phishing sites. Protect yourself by using scanners that preview URLs before navigating, being suspicious of QR stickers placed over existing codes, and verifying the domain matches the expected destination.

Q:Why should I generate QR codes client-side instead of using an API?

Server-side QR generators receive and potentially log your encoded data — WiFi passwords, contact information, or URLs. Client-side generators like ToolZeno process everything in your browser, ensuring your data never leaves your device.

Explore More Technical Guides

Design & Accessibility

Understanding Web Accessibility & WCAG 2.1 Contrast Ratios for Modern Web Apps

A comprehensive developer's masterclass on WCAG 2.1 AA/AAA color contrast standards, relative luminance math, color blindness vision deficiencies, and building accessible UI design systems.

12 min readRead
Security & Cryptography

JSON Web Tokens (JWT) Deep-Dive: Architecture, Security Standards, and Local Debugging

An in-depth security engineering guide to RFC 7519 JWT structure, digital signatures (HS256 vs RS256), token vulnerability vectors, and safe client-side debugging.

14 min readRead
Performance & Optimization

Image Optimization Strategies for Core Web Vitals: WebP, SVG, and Compression Techniques

Master image compression algorithms, next-generation WebP/AVIF file formats, SVG vector minification, and responsive image loading to achieve 100 Lighthouse performance scores.

12 min readRead
Security & Cryptography

Understanding Password Entropy, Key Derivation, and Cryptographic Hash Functions

Explore the mathematics of password entropy, NIST 800-63B security standards, salt iterations, and SHA-256 vs Argon2 key derivation functions for modern authentication systems.

13 min readRead
Developer Workflows

The Developer's Guide to Cron Expressions, Syntax Parsing, and Execution Schedules

Learn standard 5-field cron syntax, special wildcards, Quartz scheduler differences, common scheduling patterns, and how to validate background cron jobs accurately.

11 min readRead
Developer Workflows

JSON Formatting & Validation in High-Performance Web Applications

Discover best practices for parsing multi-megabyte JSON payloads, handling circular object references, schema validation, Web Worker parsing, and safe browser-based formatting.

12 min readRead
Developer Workflows

Base64 Encoding & Decoding: How It Works, When to Use It, and Common Pitfalls

A thorough technical guide to the Base64 encoding algorithm, its mathematical foundations, practical use cases in web development, and critical security misunderstandings.

11 min readRead
Developer Workflows

Regular Expressions Mastery: Pattern Syntax, Performance Traps, and Real-World Recipes

Master regex pattern syntax from fundamentals to advanced lookaheads, understand catastrophic backtracking, and learn production-tested patterns for email, URL, and data validation.

14 min readRead