DevGizmo
Back to Blog
generators·

QR Codes: How They Work and How to Generate One

QR codes encode URLs, text, and data in a 2D matrix that any smartphone can read instantly. Learn how QR codes work, what error correction levels mean, and how to generate a QR code for any purpose.

qr-codebarcodedata-encodingmobilegenerators

What Is a QR Code?

A QR code (Quick Response code) is a two-dimensional matrix barcode that encodes data as a pattern of black and white squares. Developed by Denso Wave in Japan in 1994, QR codes were originally designed for tracking automotive parts during manufacturing. Today they are ubiquitous — used for payments, URLs, Wi-Fi credentials, contact cards, product tracking, and event tickets.

Unlike a 1D barcode, which encodes data in a single row of lines, a QR code uses both horizontal and vertical dimensions, allowing it to store significantly more data in a smaller space.

Anatomy of a QR Code

A QR code has several structural elements:

Finder patterns: The three large square-in-square symbols in three corners. The scanner uses these to determine the orientation, size, and tilt of the code — QR codes can be read from any angle.

Alignment patterns: Small squares scattered through larger QR codes that help correct for perspective distortion when the code is curved or photographed at an angle.

Timing patterns: Alternating black and white modules between the finder patterns. They establish the module grid size.

Format information: A strip of modules around the finder patterns encoding the error correction level and masking pattern.

Data region: The remaining modules encode the actual payload — the URL, text, or other content.

Quiet zone: A white border of at least 4 modules around the entire code. Without it, scanners may fail to detect the code boundary.

What Can a QR Code Contain?

QR codes support four data encoding modes:

ModeContentCapacity (version 1)
NumericDigits 0–9 onlyUp to 41 characters
AlphanumericUppercase, 0–9, $%*+-./:spaceUp to 25 characters
Byte/BinaryAny 8-bit data (UTF-8 text, URLs)Up to 17 characters
KanjiShift JIS encoded Japanese charactersUp to 10 characters

URLs, which contain mixed case and special characters, use Byte mode. A QR code can theoretically encode up to 7,089 numeric characters or 4,296 alphanumeric characters at maximum capacity (version 40), though real-world use keeps them much smaller.

Versions and Capacity

QR codes come in 40 versions, from version 1 (21×21 modules) to version 40 (177×177 modules). Each version stores more data but produces a more complex pattern that requires higher resolution to scan reliably.

Practical guidelines:

  • Short URLs / ~50 characters: Version 3–5 (sufficient for most use cases)
  • Long URLs / contact cards: Version 7–10
  • Entire paragraphs of text: Version 15+

Always use the shortest URL you can (use a URL shortener if needed) — smaller QR codes scan faster and more reliably.

Error Correction Levels

One of the most important features of QR codes is error correction. Encoded redundancy allows a scanner to recover the data even if part of the code is damaged, dirty, or obscured.

LevelRecovery capacityData overheadUse case
L (Low)~7%MinimumPristine conditions, maximum data capacity
M (Medium)~15%ModerateGeneral use — good balance
Q (Quartile)~25%HighIndustrial, some dust/damage expected
H (High)~30%MaximumLogo overlaid on the QR code, harsh environments

Higher error correction = larger QR code for the same payload.

If you want to overlay a logo or image on top of a QR code (common in marketing), use Level H — the redundancy ensures the code remains readable even with 30% of the modules obscured by the logo.

How QR Code Scanning Works

  1. Locate — The scanner finds the three finder patterns to detect and orient the code.
  2. Sample — The timing patterns establish the module grid.
  3. Read format — Error correction level and mask pattern are decoded.
  4. Unmask — A mathematical mask is removed from the data region (applied during generation to prevent large uniform areas that confuse scanners).
  5. Decode — The data modules are read in a specific zigzag order and the Reed-Solomon error correction is applied.
  6. Interpret — The byte string is interpreted according to the encoding mode (numeric, alphanumeric, byte, Kanji).

Common QR Code Use Cases

URLs and Web Links

The most common use. Paste any URL and generate a QR code for posters, business cards, or product packaging.

Wi-Fi Network Credentials

Format: WIFI:S:NetworkName;T:WPA;P:password;; Scanning this opens a prompt to join the Wi-Fi network automatically — no typing required.

Contact Information (vCard)

A QR code encoding a vCard lets someone scan your business card and save your contact details instantly.

Payments

WeChat Pay, Alipay, and many banking apps use QR codes to encode payment addresses. The recipient displays a QR code; the payer scans it to initiate a transfer.

Event Tickets

QR codes on event tickets encode a unique identifier that scanners verify against a database, preventing fakes.

Tips for Reliable QR Codes

  1. Test before printing — always scan the generated code with multiple devices before printing at scale.
  2. Use high contrast — black on white is optimal. Avoid low-contrast colour combinations (light on light, dark on dark).
  3. Include a quiet zone — most generators handle this automatically, but verify when placing the code on a design.
  4. Keep URLs short — use a URL shortener or custom short domain to minimise code complexity.
  5. Match error correction to context — use Level H if you're adding a logo; Level M is fine for simple printed codes.
  6. Minimum print size — for a standard smartphone camera, a QR code should be at least 2cm × 2cm (0.8" × 0.8"). Larger is better for distance scanning.

Use the QR Code Generator

The QR Code Generator on DevGizmo lets you enter any URL or text, choose an error correction level, and instantly generate a downloadable QR code — all in your browser with no data sent to a server.

Try it yourself

Put these concepts into practice with the free online tool on DevGizmo.