QR Code Error Correction — L, M, Q, H Levels Explained
QR codes have four error correction levels: L (7%), M (15%), Q (25%), H (30%). Higher levels allow more damage tolerance but create larger/denser codes. Learn which level to...
QR code error correction allows damaged or partially obscured codes to still scan. The four levels trade off between damage tolerance and code density (size).
Use the QR Code Generator to generate QR codes with any error correction level.
Error correction levels
| Level | Name | Data recovery | Use case |
|---|---|---|---|
| L | Low | 7% | Clean environments, digital display |
| M | Medium | 15% | General purpose (default) |
| Q | Quartile | 25% | Printed labels, logos embedded |
| H | High | 30% | Industrial environments, outdoor signage |
“Data recovery” means the percentage of the codewords that can be restored even if that portion is damaged, dirty, or obscured.
How error correction affects QR size
Higher correction levels store more redundant data, requiring more modules (black/white squares):
Same data ("https://example.com") at different levels:
Level L: 25×25 modules (Version 2)
Level M: 25×25 modules (Version 2)
Level Q: 29×29 modules (Version 3)
Level H: 33×33 modules (Version 4)
The code gets physically larger (denser) with higher correction.
Choosing the right level
L (7%) — Use when:
- Code displayed on screen (no physical damage risk)
- Need maximum data in minimum space
- Controlled clean environment
M (15%) — Use when:
- General purpose printed QR codes
- Standard business cards, posters
- No embedded logo needed
Q (25%) — Use when:
- Logo or design element will overlay the center
- Slightly degraded print quality expected
- Product packaging with wear
H (30%) — Use when:
- Industrial/outdoor use (dirt, moisture, partial damage)
- Very small printed size
- Guaranteed scanning in harsh conditions
- Custom design with significant overlaid artwork
Logo overlay and error correction
A popular QR code design embeds a brand logo in the center. This works because:
- The center overlays ~10-15% of the code
- Error correction can recover that data
- Level Q or H ensures enough redundancy
// JavaScript: generate QR code with center logo using qrcode npm:
import QRCode from 'qrcode';
async function generateQRWithLogo(text, logoUrl) {
const canvas = document.createElement('canvas');
const size = 300;
await QRCode.toCanvas(canvas, text, {
errorCorrectionLevel: 'H', // High for logo overlay
width: size,
margin: 2,
});
const ctx = canvas.getContext('2d');
const logo = new Image();
logo.src = logoUrl;
await new Promise(resolve => logo.onload = resolve);
const logoSize = size * 0.2; // 20% of QR code
const logoX = (size - logoSize) / 2;
const logoY = (size - logoSize) / 2;
ctx.fillStyle = 'white';
ctx.fillRect(logoX - 4, logoY - 4, logoSize + 8, logoSize + 8);
ctx.drawImage(logo, logoX, logoY, logoSize, logoSize);
return canvas.toDataURL('image/png');
}
Reed-Solomon error correction
QR codes use Reed-Solomon error correction codes, the same algorithm used in CDs and DSL:
Reed-Solomon overview:
- Data is treated as polynomial coefficients
- Generator polynomial derives error correction codewords
- Can detect and correct errors up to (n-k)/2 symbols
where n = total codewords, k = data codewords
Example for Level M, Version 1 (21×21):
- Total: 26 codewords
- Data: 16 codewords
- EC: 10 codewords
- Can correct up to 5 symbol errors
Generating QR codes with specific levels in code
// qrcode library (npm):
import QRCode from 'qrcode';
// SVG output, Level H:
const svgString = await QRCode.toString('https://example.com', {
type: 'svg',
errorCorrectionLevel: 'H',
margin: 2,
width: 256,
color: {
dark: '#1e293b',
light: '#ffffff',
},
});
// PNG buffer, Level M:
const buffer = await QRCode.toBuffer('https://example.com', {
errorCorrectionLevel: 'M',
width: 512,
});
# Python: qrcode library
import qrcode
qr = qrcode.QRCode(
version=None, # auto-select
error_correction=qrcode.constants.ERROR_CORRECT_H,
box_size=10,
border=4,
)
qr.add_data('https://example.com')
qr.make(fit=True)
img = qr.make_image(fill_color='black', back_color='white')
img.save('qr_high.png')
Related tools
- QR Code Generator — generate QR codes with custom settings
- QR Code Maker — QR code creation guide
- QR Code for Website — QR codes for URLs
Related posts
- How QR Codes Work — and How to Make Ones That Actually Scan — QR codes aren't magic. Finder patterns, Reed-Solomon error correction, version s…
- Create QR Code — Generate QR Codes for URLs, Text, and Contacts — Creating a QR code takes your URL, text, or contact data and encodes it as a sca…
- Dynamic QR Code vs Static QR Code — What's the Difference? — Dynamic QR codes use a redirect URL that can be changed after printing. Static Q…
- QR Code Creator — Generate Custom QR Codes for Business Use — A QR code creator generates QR codes for business cards, menus, marketing materi…
- QR Code Maker — Create QR Codes for Any URL, Text, or Contact — A QR code maker generates scannable QR codes from URLs, text, phone numbers, ema…
Related tool
Generate QR codes for URLs, text, Wi-Fi, contact cards. Custom size, colors, error correction. Download as PNG or SVG. 100% client-side.
Written by Mian Ali Khalid. Part of the Dev Productivity pillar.