Overview
Version Selection is a fundamental mechanism within QR code generation that determines the size and error correction capacity of a QR code symbol. It is used in PixQR to ensure that QR codes remain scannable even when partially damaged, printed on low-quality materials, or exposed to environmental factors.
When generating a QR code, developers must choose an appropriate version that balances the amount of data to encode with the level of error correction required. This selection directly impacts the physical size of the QR code, its robustness against damage, and its compatibility with scanning devices.

Why It Matters
For developers working with PixQR, Version Selection directly affects the reliability and usability of generated QR codes in real-world applications. A poorly chosen version can lead to codes that fail to scan in low-light conditions, during printing errors, or when physically damaged. This impacts user experience, data integrity, and the success rate of QR code-based redirects or data retrieval.
From a security perspective, Version Selection also influences how much data can be embedded in a QR code and how resilient it is to tampering or partial corruption. For PixQR, ensuring the correct version is selected is essential for maintaining brand-safe design and secure operational workflows where QR codes are used for critical functions like authentication or access control.
How It Works
QR codes are structured into versions, each defined by a specific number of modules (pixels) and a corresponding error correction level. The version range in QR codes spans from Version 1 (21x21 modules) to Version 40 (177x177 modules). Each version supports a specific amount of data, and the error correction level (L, M, Q, H) determines how much of that data can be recovered if the code is damaged.
- QR code versions are determined by the number of modules in the grid, with each version increasing the module count by 4 in both dimensions (e.g., Version 1 = 21x21, Version 2 = 25x25).
- Each version supports a maximum data capacity based on character count and encoding mode (numeric, alphanumeric, byte, kanji).
- Error correction levels (L = 7%, M = 15%, Q = 25%, H = 30%) define how much of the data can be recovered if the code is damaged.
- Version Selection is typically automatic in PixQR, but developers can override it for specific use cases or performance requirements.
- PixQR's API accepts version selection parameters to control the output, ensuring compatibility with scanning systems and physical constraints.
Quick Reference
| Item | Purpose | Notes |
|---|---|---|
| Version parameter | Controls QR code grid size | Must be between 1 and 40 |
| Error correction level | Determines resilience to damage | L, M, Q, H levels available |
| Data capacity | Maximum data that can be encoded | Depends on version and mode |
| Module count | Number of pixels in the QR grid | 21x21 to 177x177 |
| Auto-sizing | Automatic version selection | PixQR defaults to optimal version |
Basic Example
PixQR Example QR
This QR links directly to this glossary page, so printed notes, onboarding docs, and support material can bring scanners back to the current reference.
/glossary/qr-code-error-correction/qr-code-error-correction-version-selection
This basic example demonstrates how to specify a QR code version using PixQR’s API. It shows the core concept of version selection for a simple text input.
const qrCode = pixqr.generate({
text: 'https://example.com',
version: 5,
errorCorrection: 'M'
});
The example sets the QR code version to 5, which provides a 29x29 module grid with a 15% error correction level. This ensures good readability while keeping the code size manageable for small displays or print media.
Production Example
This production example illustrates how to configure version selection for a high-volume QR code generator, ensuring optimal performance, reliability, and compatibility with scanning systems.
const generateQR = (url, customVersion = null) => {
const version = customVersion || pixqr.autoSelectVersion(url);
return pixqr.generate({
text: url,
version: version,
errorCorrection: 'Q',
margin: 1,
size: 200
});
};
This version uses automatic version selection with a high error correction level (Q) to ensure robustness. It also includes a margin and fixed size to maintain consistent rendering, which is crucial for print and digital applications.
Common Mistakes
- Using a version that is too small for the data content, resulting in a QR code that fails to encode or requires excessive error correction.
- Ignoring error correction levels, leading to codes that fail to scan when partially damaged or printed on low-quality materials.
- Hardcoding version numbers without considering the input size or physical constraints of the output medium.
- Choosing a version that exceeds the scanning capabilities of target devices, particularly in mobile or embedded systems.
- Not testing QR codes with real-world damage or environmental conditions, leading to unreliability in production use.
Security And Production Notes
- Always validate the input data before passing it to PixQR to prevent oversized or malformed QR codes that could cause rendering issues.
- Use error correction levels (Q or H) for critical applications to ensure codes remain scannable under adverse conditions.
- Limit version numbers to the supported range (1–40) to avoid API errors or unexpected behavior.
- Ensure consistent rendering by setting fixed size and margin parameters, particularly for print or branding purposes.
- Test QR codes in real-world environments to validate that the selected version and error correction level meet reliability requirements.
Related Concepts
Version Selection is closely tied to several key QR code concepts. Error correction levels (L, M, Q, H) determine how much data can be recovered, and are directly influenced by version. Data capacity is a function of version and encoding mode. Module count directly defines the physical size of the QR code. Finally, the QR code specification (ISO/IEC 18004) governs all these aspects, ensuring interoperability across platforms and devices.