# Penalty score

> The penalty score is how a QR encoder chooses among the eight mask patterns. Each candidate symbol is scored by four rules (long same-colour runs, 2 × 2 blocks, false finder patterns and dark/light imbalance) weighted 3, 3, 40 and 10, and the mask with the lowest total is used.

Source: https://useqr.app/glossary/penalty-score · Last reviewed 2026-08-21 · UseQR is free forever, no signup.

---

## The four rules

After data placement, the encoder applies each [mask pattern](/glossary/mask-pattern) in
turn and scores the result:

| Rule | Looks for | Penalty |
|---|---|---|
| N1 | Runs of 5+ same-colour [modules](/glossary/module) in a row or column | 3 + (length − 5) |
| N2 | Every 2 × 2 block of one colour | 3 each |
| N3 | The 1:1:3:1:1 dark/light ratio of a finder, with 4 light modules beside it | 40 each |
| N4 | Deviation of overall darkness from 50% | 10 per 5% step |

Lowest total wins. N3's weight of 40 exists because a fake
[finder pattern](/glossary/finder-pattern) in the data region is the most expensive defect
possible: a scanner could lock onto the false corner and fail to find the symbol at all.
The chosen mask number is then recorded in the
[format information](/glossary/format-information).

## Why identical data can yield different codes

The rules sound exact but are implemented unevenly: several major encoders score N3 without
checking the four light modules the standard requires next to the 1:1:3:1:1 run, and a
one-point difference flips which mask wins. Both results decode identically, the score
only tunes scannability. This is a principal reason
[two generators produce visually different codes](/docs/spec/why-two-generators-produce-different-codes)
from the same input, and why "my code looks different" is not a bug report. The full
scoring walkthrough lives at
[mask selection penalty scores](/docs/spec/mask-selection-penalty-scores); the exact
per-mask formulas are in the [mask pattern reference](/docs/reference/mask-pattern-reference).

## FAQ

### What is a good penalty score for a QR code?
There is no target number. The score only ranks the eight mask candidates for one symbol against each other; the encoder simply keeps the lowest and discards the value.

### Does the penalty score affect whether my QR code scans?
Marginally. Masking prevents pathological patterns (big single-colour areas and false finders), but any of the eight masks produces a valid, decodable symbol. Contrast, size and quiet zone matter far more.

## Try it

- https://useqr.app/url
- https://useqr.app/validate
