How QR Codes Work: Versions, Error Correction and Safe Use
What the squares in a QR code mean, how versions and error correction levels trade size for robustness, how Wi-Fi and contact codes are encoded, and how to print them.
What you are looking at
The QR (Quick Response) code was developed by the Japanese company Denso Wave in 1994 to track car parts, and the format is now an international standard, ISO/IEC 18004. Every QR code is a square grid of modules — the small dark and light squares. Each module is one bit. Some modules hold your data, and the rest form fixed patterns that help the scanner find the code and read it.
- Finder patterns. The three big squares-within-squares in the top-left, top-right and bottom-left corners. Their 1:1:3:1:1 ratio of dark and light stays the same from any angle, so a camera can spot the code, work out how it is rotated and correct for tilt. There is no fourth square, which is how the scanner knows which way up the code is.
- Timing patterns. A dotted line of alternating modules runs between the finder patterns, horizontally and vertically. It tells the decoder how big the grid is and where each column and row falls.
- Alignment patterns. Smaller squares, found in every version from 2 upwards (larger versions have several). They help correct for a curved or skewed surface.
- Format and version information. Short strips next to the finder patterns record the error-correction level and the mask pattern. From version 7 upwards, the version number is stored as well. This information is stored twice, so the code still works if one copy is damaged.
- Quiet zone. The empty light border around the code. It is part of the specification, not decoration: without it the scanner cannot tell where the code ends.
The encoder also applies one of eight mask patterns, choosing the one that leaves the fewest large blocks of one colour and the fewest shapes that look like finder patterns. That is why codes for nearly identical text can look completely different.
Versions: why some codes are denser than others
QR codes come in 40 sizes called versions. Version 1 is 21 × 21 modules, and each version adds 4 modules per side, up to version 40 at 177 × 177. The encoder automatically chooses the smallest version that fits your content at the error-correction level you asked for. The table below shows real results from the qrcode library, the same library the QR code generator uses.
| Content | Characters | Level L | Level M | Level Q | Level H |
|---|---|---|---|---|---|
| tel:+15551234567 | 16 | v1 (21 × 21) | v1 (21 × 21) | v1 (21 × 21) | v2 (25 × 25) |
| https://toolywise.com | 21 | v2 (25 × 25) | v2 (25 × 25) | v3 (29 × 29) | v3 (29 × 29) |
| A Wi-Fi network with a 21-character password | 51 | v3 (29 × 29) | v4 (33 × 33) | v5 (37 × 37) | v6 (41 × 41) |
| A shop URL with three UTM tracking parameters | 116 | v6 (41 × 41) | v7 (45 × 45) | v9 (53 × 53) | v10 (57 × 57) |
Look at the last row: tracking parameters more than quadrupled the URL’s length, and the code grew from 25 to 45 modules across. At the same printed size each module is much smaller and harder to scan. Short URLs make better QR codes.
Encoding modes
The standard packs data in different modes. Numeric mode stores digits only, about 3.3 bits per digit. Alphanumeric mode covers 0–9, uppercase A–Z, the space and $ % * + - . / :, at 5.5 bits per character. Byte mode handles anything else, including lowercase letters and UTF-8 text such as accented letters or emoji, at 8 bits per byte. A Kanji mode exists for Japanese text. The library splits your text into segments and uses the most compact mode for each part. In a Wi-Fi string, for example, the uppercase WIFI:T:WPA prefix can use alphanumeric mode, while the network name and password usually need byte mode.
| Level | Digits only | Alphanumeric | Bytes (e.g. lowercase text, URLs) |
|---|---|---|---|
| L | 7,089 | 4,296 | 2,953 |
| M | 5,596 | 3,391 | 2,331 |
| Q | 3,993 | 2,420 | 1,663 |
| H | 3,057 | 1,852 | 1,273 |
Error correction: L, M, Q and H
QR codes use Reed–Solomon error correction, the same family of codes used on CDs. The data is split into codewords, and extra codewords are added so the decoder can rebuild ones that are missing or wrong. Each of the four levels gives up some capacity in exchange for that robustness.
| Level | Approx. codewords recoverable | Good for |
|---|---|---|
| L (Low) | 7% | Long content shown on clean screens, where damage is unlikely |
| M (Medium) | 15% | The sensible default for print and screens — the generator starts here |
| Q (Quartile) | 25% | Signs, labels and packaging that may get scuffed or dirty |
| H (High) | 30% | Harsh environments, or a code with a small logo placed over its centre |
Higher is not automatically better. Each step up adds modules, as the version table shows, so at a fixed print size the modules get smaller. For a clean flyer, M usually scans better than H. Use the higher levels when the code will be damaged, partly covered or printed on a rough or curved surface. If you add a logo yourself in a design program, use H, keep the logo small and central, and never cover the three finder patterns.
What goes inside: URLs, Wi-Fi, email, phone and contacts
A QR code only stores text. Your phone decides what to do with that text from its format. These are the exact strings the Toolywise generator builds for each content type:
| Type | String encoded | Notes |
|---|---|---|
| URL | https://example.com/menu | Encoded as typed, with leading and trailing spaces removed. Include https:// so phones treat it as a link. |
| Text | Any text, unchanged | Line breaks and Unicode are kept. Scanners show it as plain text. |
| Wi-Fi | WIFI:T:WPA;S:Café\;Guest;P:p@ss\:word;; | T is the security type (WPA, WEP or nopass), S the network name, P the password, and H:true marks a hidden network. A backslash goes before any \ ; , : or " in the name or password. |
| mailto:hello@example.com?subject=Table%20booking | Subject and body are percent-encoded, with spaces written as %20. | |
| Phone | tel:+15551234567 | Everything except digits and + is removed, so “+1 (555) 123-4567” becomes +15551234567. |
The Wi-Fi format was popularised by the open-source ZXing barcode project, and Android and iOS camera apps both understand it. The mailto: and tel: schemes are internet standards (RFC 6068 and RFC 3966). If you build a URL with query parameters yourself, characters such as &, # and spaces must be percent-encoded. The URL encoder does this for you.
Contact cards (vCard). The generator has no separate contact form, but a vCard is also just text. Paste a block like the one below into the Text option, and most phone cameras will offer to save it as a contact. Keep it short: every field makes the code denser.
BEGIN:VCARD · VERSION:3.0 · FN:Jane Doe · TEL:+15551234567 · EMAIL:jane@example.com · END:VCARD — put each item on its own line, without the dots.
Static vs “dynamic” QR codes
Every code the generator makes is static: your URL, network name or text is stored in the pattern itself. It needs no server, works offline (for text, Wi-Fi and contacts), cannot be tracked and never expires. The downside is that it can never be changed. A typo in a printed URL is there for good.
So-called dynamic QR codes are not a different kind of barcode. They are static codes that contain a short link to a redirect service, such as qr-service.example/x7Kp2. When someone scans the code, the service logs the scan (time, rough location and device type) and then forwards the phone to the real destination. That is what makes the destination editable and gives you scan statistics. It is also why such codes can “expire”: if the subscription lapses or the company shuts down, the service stops redirecting, and every printed copy stops working.
You can get the main benefit without being locked in. Point a static code at a page on a domain you control, for example yoursite.com/menu, and change what that page shows or where it redirects whenever you like. Use your own analytics if you need scan counts.
Printing: size, contrast and the quiet zone
- Size by module, not just by code. What matters is how big each module is. A version 2 code (25 modules) plus the generator’s 2-module margin is 29 modules wide. Printed 2 cm wide, each module is about 0.7 mm. Put a version 7 code in the same 2 cm and each module is under half that size. Longer content needs a bigger print.
- Scanning distance. A rule of thumb many printers use is that a code scans from up to about ten times its width. A 3 cm code works at arm’s length; a poster read from across a room needs a code tens of centimetres wide. Test with the phones your audience is likely to use.
- Quiet zone. The specification asks for a light border four modules wide. The generator adds a two-module margin to the PNG and SVG files, which most phone cameras accept. When you place the code in a design, leave at least that much extra empty space around it, and never put text or images right up to its edge.
- Contrast. Use a dark code on a light background. The generator warns when the contrast ratio between your two colours falls below 3:1. Light-on-dark (inverted) codes are not read by every scanner, so avoid them for anything important.
- Format. Use the SVG download for print. It is vector, so it stays sharp at any size. Use PNG for screens and documents, choosing at least a few pixels per module.
- Surfaces. Glossy laminate reflects light and tight curves distort the grid. Matte, flat areas scan best. Always scan a printed proof before a full run.
Security: “quishing” and how to scan safely
People cannot read a QR code before they scan it, and that makes codes useful to scammers. QR phishing, sometimes called quishing, includes fake stickers placed over the real codes on parking meters and restaurant tables, and emails that ask you to scan a code to “re-verify your account”. Email filters that check links often cannot read a link that is hidden inside an image.
- Before opening a link, read the address your camera shows. Look for misspelled brand names and odd domains.
- Be suspicious of any code that leads straight to a login or payment page, especially one that arrived unexpectedly by email or text message.
- In public places, check whether the code is a sticker on top of another code.
- Remember that a Wi-Fi code contains the password in plain text. Anyone who photographs the code can read it, so share a guest network rather than your main one.
If you create codes for others, use a domain people recognise and print the URL as text next to the code, so they can check it or type it in.
Sources
- DENSO WAVE – QR code information (qrcode.com)
- DENSO WAVE – Error correction feature
- DENSO WAVE – Information capacity and versions
- ISO/IEC 18004 – QR Code bar code symbology specification
- ZXing wiki – Barcode contents (Wi-Fi and other formats)
- RFC 6068 – The “mailto” URI scheme
- RFC 3966 – The tel URI for telephone numbers
Results are estimates for planning and education, not tax, legal, financial or medical advice. Check important decisions with a qualified professional.