Developer Utilities

How QR Codes Work and How to Make Ones That Actually Scan

How QR Codes Work and How to Make Ones That Actually Scan

QR codes link the physical world to the digital one: menus, tickets, payments, Wi-Fi sign-in and business cards. Making one is easy. Making one that scans reliably takes a few precautions.

What is inside a QR code

A QR (Quick Response) code stores data as a grid of black and white squares called modules. Several features help scanners:

  • Three large corner squares (finder patterns) tell the scanner where the code is and how it is rotated.
  • Timing patterns help the scanner measure the grid.
  • Alignment patterns (in larger codes) correct for distortion.
  • Format and version information describe the size and settings.
  • Data and error-correction modules hold your content plus extra redundancy.

Error correction

QR codes include Reed–Solomon error correction in four levels:

  • L: recovers about 7 percent of damaged data
  • M: about 15 percent
  • Q: about 25 percent
  • H: about 30 percent

Higher levels survive scratches and logos placed in the middle, but they make the code denser for the same content. Choose M for most uses and H if a logo covers part of the code.

Keep the content short

The more text you encode, the more modules are needed and the harder the code is to scan at small sizes. For websites, use a short URL. Avoid long tracking parameters.

Rules for reliable scanning

  1. Contrast: dark code on a light background. Inverted (light on dark) codes fail on many readers.
  2. Quiet zone: leave an empty border of at least four modules around the code.
  3. Size: a common rule is a scanning distance of about ten times the code's width, so a code scanned from 1 metre should be around 10 cm wide.
  4. Flat surface: avoid placing codes on curved or glossy surfaces that reflect light.
  5. Resolution: print vector or high-resolution images so edges stay sharp.

Static vs dynamic codes

A static code stores the data itself and can never be changed. A dynamic code stores a short redirect address, which lets you change the destination later and track scans, but it depends on the service staying online. For printed material you cannot easily replace, consider the long-term reliability of the redirect.

Useful content types

Besides URLs, QR codes can store plain text, email addresses, phone numbers, SMS messages, Wi-Fi credentials and contact cards (vCard).

Safety

Scanning a code can open a malicious page. Preview the link before opening it, and be suspicious of stickers placed over legitimate codes. If you publish codes, put them in places that are hard to tamper with and add a short URL in text beside the code.

Test before you print

Scan your code with at least two different phones in the actual lighting where it will be used.

A tidy, high-contrast code with a short link will scan quickly every time.

Keep reading