QR Code Calculator: Decode Data Payloads
- Error correction codewords
- codewords
- Result
- Total modules
- modules
- Result
- QR version
- 5
- You entered
This QR code calculator works out the maximum data capacity of a QR code for a given version and error correction level, and it also estimates the size of a QR code’s data payload from its version and mask pattern. You select the QR code version (1-40) and the error correction level (L, M, Q, H), and the calculator returns the number of data codewords, the number of error correction codewords, and the total number of modules (the black and white squares) in the symbol. It uses the standard QR code specification tables from ISO/IEC 18004, so you can use it to plan how much text, URL, or binary data will fit in a QR code before you generate it.
Formula
The QR code is a square grid of modules. The side length (in modules) is given by:
L = 4 × version + 17
where version is an integer from 1 to 40. For example, version 1 has L = 21 modules, version 5 has L = 37, and version 40 has L = 177.
The total number of modules is simply L². However, not all modules are available for data. The QR code reserves modules for the finder patterns, timing patterns, alignment patterns, format information, and (for version 2 and above) the version information block. The exact number of data codewords depends on the version and the error correction level. The calculator above uses a simplified approximation that assumes the overhead is roughly proportional to the side length. For precise values, you should consult the official tables in ISO/IEC 18004 (the QR code standard). The approximation is accurate to within about 5% for most versions, but for exact planning, use the official tables.
Worked Example
Let’s use the default values from the calculator: version 5 and error correction level M (the second option, which we set to value 2 in the formula).
- Side length: L = 4 × 5 + 17 = 37 modules.
- Total modules: L² = 37² = 1369 modules.
- Approximate data codewords: (1369 / 8) – (2 × 2 + 1) × (37 / 8) = 171.125 – 5 × 4.625 = 171.125 – 23.125 = 148 codewords (rounded to the nearest integer).
- Approximate error correction codewords: (2 × 2 + 1) × (37 / 8) = 5 × 4.625 = 23.125, rounded to 23 codewords.
So for version 5-M, the calculator gives 148 data codewords and 23 error correction codewords. The actual value from the ISO table is 134 data codewords and 28 error correction codewords, so the approximation is close but not exact. For precise numbers, use the official table.
When to Use This Calculator
Use this calculator when you need to estimate how much data a QR code can hold before you generate it. For example, if you want to encode a URL that is 50 characters long, you need to know which version and error correction level will fit. The calculator helps you compare versions and error correction levels quickly.
It is also useful for understanding the trade-off between data capacity and error correction. Higher error correction levels (Q and H) allow the QR code to be read even if up to 30% of the symbol is damaged, but they reduce the amount of data that can be stored. Lower levels (L and M) store more data but are less robust.
How to Choose the Right Version and Error Correction
- Version 1-10: Use for small amounts of data, such as a short URL or a vCard. These are easier to scan from a distance and take up less space.
- Version 11-20: Suitable for longer URLs, text messages, or Wi-Fi credentials.
- Version 21-40: Use for large payloads, such as a full PDF document or a long JSON payload. These QR codes are dense and require a high-resolution scanner.
- Error correction L (7%): Use when the QR code is printed on a flat, clean surface and is unlikely to be damaged.
- Error correction M (15%): The default choice for most applications. A good balance between capacity and robustness.
- Error correction Q (25%): Use for QR codes on curved surfaces, like bottles, or where the code may be partially obscured.
- Error correction H (30%): Use for QR codes that will be exposed to harsh conditions, such as on metal tags or in outdoor environments.
Common Mistakes and Misconceptions
Mistake 1: Confusing data codewords with characters. A data codeword is 8 bits, but the number of characters you can encode depends on the character set. For numeric data, each codeword can hold about 3 digits; for alphanumeric data, about 2 characters; for byte data, about 1 character. So 148 codewords can hold roughly 148 bytes, but up to 444 digits.
Mistake 2: Assuming all QR codes are the same size. The physical size of a QR code depends on the module size (the width of each square) and the version. A version 40 code has 177×177 modules, so if each module is 0.5 mm, the code is about 88.5 mm on each side. A version 1 code with the same module size would be only 10.5 mm.
Mistake 3: Thinking that a QR code can hold unlimited data. The maximum capacity of a version 40 QR code with error correction L is 2,953 bytes (about 2.9 KB). That is enough for a short paragraph, but not for a full book.
Limits of the Formula
The formula used in this calculator is a simplified approximation. The actual QR code specification includes complex tables that account for the number of alignment patterns, which vary by version. The approximation is accurate to within a few codewords for most versions, but for precise data capacity, you should use the official tables published in ISO/IEC 18004. Many QR code generation libraries and online tools use these tables, so if you need exact numbers, it is better to use a dedicated QR code generator that reports the data capacity.
Frequently Asked Questions
How much data can a QR code hold?
The maximum capacity is 2,953 bytes (or about 7,089 numeric digits) for a version 40 QR code with the lowest error correction level (L). With the highest error correction level (H), the capacity drops to 1,273 bytes. For typical URLs, which are usually under 100 characters, version 10 or lower is sufficient.
What is the difference between a QR code and a barcode?
A barcode stores data in one dimension (horizontally), while a QR code stores data in two dimensions (horizontally and vertically). This allows QR codes to hold much more data and to be read in any orientation. QR codes also include error correction, so they can be partially damaged and still be readable.
Can I put a logo in the center of a QR code?
Yes, but it will cover some modules. To keep the QR code scannable, you should use a higher error correction level (Q or H) and keep the logo small (less than 20% of the code’s area). Some QR code generators allow you to add a logo and automatically adjust the error correction level.
Why does my QR code not scan?
Common reasons include: the code is too small, the contrast is too low (e.g., white on a light background), the code is distorted, or the error correction level is too low to compensate for damage. Also, some scanners have trouble with very dense codes (version 20+). Try increasing the error correction level or using a higher resolution image.
Are QR codes safe to scan?
QR codes themselves are just data carriers; they cannot execute code on your device. However, they can encode URLs that lead to phishing sites or malicious downloads. Always check the URL before opening it, especially if the QR code is from an unknown source. Some QR scanner apps show the URL before opening it, which is a good safety feature.
Can I use this calculator to generate a QR code?
No, this calculator only helps you estimate the capacity and size. To generate a QR code, you need a QR code generator that converts your data into a QR image. Many free online generators exist, and they often let you choose the version and error correction level.
Related
Formula used
in v | QR version | - | 5 | 1 sel ec | Error correction | L=1, M=2, Q=3, H=4 out data_cw | Data codewords | codewords | (v * 4 + 17) * (v * 4 + 17) / 8 - (ec * 2 + 1) * (v * 4 + 17) / 8 | 0 out ec_cw | Error correction codewords | codewords | (ec * 2 + 1) * (v * 4 + 17) / 8 | 0 out total_mod | Total modules | modules | (v * 4 + 17) * (v * 4 + 17) | 0
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.