Skip to content

How to Create QR Codes: A Complete Developer Guide

QR codes (Quick Response codes) are two-dimensional barcodes that can store URLs, text, contact information, Wi-Fi credentials and more. Originally invented in 1994 by Denso Wave for tracking automotive parts, QR codes are now everywhere, from restaurant menus to payment systems.

How QR Codes Work

A QR code encodes data into a grid of black and white squares called modules. The three large squares in the corners are finder patterns that help scanners detect and orient the code. The data is encoded using Reed-Solomon error correction, which means the code can still be read even if part of it is damaged or obscured.

QR codes have 40 versions, where each version adds more modules to the grid. Version 1 is 21x21 modules and can store about 25 characters. Version 40 is 177x177 modules and can store up to 4,296 alphanumeric characters.

What Data Can QR Codes Store?

  • URLs. The most common use case. Scanning opens the URL in a browser.
  • Plain text. Any string of text up to the size limit.
  • Wi-Fi credentials. Format: WIFI:T:WPA;S:NetworkName;P:Password;;
  • vCard contacts. Store name, phone, email and address in a scannable format.
  • Email. Pre-fill recipient, subject and body using mailto: format.
  • SMS. Pre-fill phone number and message using sms: format.
  • Geo coordinates. Open a map location using geo: format.

Error Correction Levels

QR codes support four error correction levels. Higher levels allow more of the code to be damaged while still being readable, but they also increase the size of the code:

LevelRecoveryBest For
L (Low)~7%Digital screens, clean environments
M (Medium)~15%General purpose (default)
Q (Quartile)~25%Printed materials
H (High)~30%Codes with logos, outdoor use

QR Code Size Best Practices

  • Keep data short. Shorter data means a simpler QR code that is easier to scan. Use URL shorteners for long links.
  • Minimum print size. For reliable scanning, print QR codes at least 2cm x 2cm (about 0.8 inches). Larger codes scan better from a distance.
  • Quiet zone. Always maintain a white border (quiet zone) of at least 4 modules around the code. Without it, scanners may fail.
  • Contrast. Dark modules on a light background works best. Avoid low-contrast color combinations.

Generating QR Codes Programmatically

Most programming languages have QR code libraries. In JavaScript, qrcode is the most popular npm package. Python has qrcode and segno. Go has go-qrcode. These libraries let you control size, error correction level, colors and output format (PNG, SVG, or canvas).

Generate a QR code now

Enter any URL or text to instantly generate a downloadable QR code.

Open QR Code Generator