How much fits in a QR code
| Error correction | Max bytes (version 40) | Use when |
|---|---|---|
| L | 2,953 | Clean screens and prints where nothing covers the code |
| M | 2,331 | The usual default |
| Q | 1,663 | Printed on things that get scuffed, like packaging |
| H | 1,273 | When a logo is placed over the middle |
Text is stored as UTF-8, so a Chinese character takes 3 bytes and an emoji 4. Shorter content gives a smaller, less dense code that’s easier to scan, so keep URLs short.
Generating QR codes in code
qrencode -o code.png -s 10 'https://example.com'
qrencode -t SVG -o code.svg 'WIFI:T:WPA;S:Office;P:secret;;'
qrencode -t ANSIUTF8 'https://example.com' # print in the terminal
# pip install "qrcode[pil]"
import qrcode
img = qrcode.make("https://example.com", error_correction=qrcode.constants.ERROR_CORRECT_M)
img.save("code.png")
import QRCode from 'qrcode';
const svg = await QRCode.toString('https://example.com', { type: 'svg', errorCorrectionLevel: 'M' });
await QRCode.toFile('code.png', 'https://example.com', { width: 1024 });
Encoding a URL with query parameters? Check it with the URL parser first. Making icons for the site the code points to? Try the favicon generator.
Frequently asked questions
Do these QR codes expire?
No. The content is stored in the code itself, so it works forever and doesn’t depend on this site. Many “free QR code” services instead encode a short link to their own server so they can count scans; those “dynamic” codes stop working when the subscription ends or the service shuts down. If you need scan statistics, encode a URL with UTM parameters and read them in your analytics.
How do Wi-Fi QR codes work?
They contain a text like WIFI:T:WPA;S:Office;P:secret;;. The camera apps on iPhone (iOS 11 and later) and Android recognise this format and offer to join the network. Special characters in the network name or password (\ ; , : ") are escaped with a backslash automatically.
Which error correction level should I choose?
Higher levels let the code be read even when part of it is dirty, damaged or covered, at the cost of more modules (a denser code). M is a good default. Use H if you plan to put a logo in the middle, and L to keep a long URL from producing a very dense code.
SVG or PNG?
SVG for print and design tools: it’s a vector, so it stays sharp at any size and is tiny. PNG for places that only take images, such as slides, documents and social posts; pick a size of at least 1024px for print.
Why won’t my code scan?
Common causes: too little contrast, light modules on a dark background (some readers can’t handle inverted codes), no white margin around the code (the spec asks for 4 modules of quiet zone), or a code printed too small for its density. A rule of thumb is that the code should be at least a tenth as wide as the scanning distance.