NHS Number Validator
Validate UK National Health Service numbers. Excellent for your tests.
How NHS validation works
The validator checks if the input is exactly 10 digits. It calculates the weighted sum of the first 9 digits using weights from 10 to 2.
If the division remainder indicates a check digit of 10, the number is rejected as invalid. A remainder of 11 maps to check digit 0, and other values must match the 10th digit.
Anatomy & Structure of NHS Number (10 Digits)
The National Health Service patient identifier consists of 10 numeric digits:
| Position | Field | Length | Meaning & Rule | Example |
|---|---|---|---|---|
| 1 to 9 | Patient Identifier | 9 digits | Unique sequential patient index in NHS England and Wales | 943476591 |
| 10 | Check Digit | 1 digit | Modulo 11 checksum digit (numbers resulting in 10 are discarded) | 9 |
NHS Number Validation Algorithm (Modulo 11)
The official NHS formula weights the first 9 digits from 10 down to 2:
CheckDigit = 11 - (sum(d_i * (11 - i)) % 11)
- 1. Multiply each of the first 9 digits by weights: [10, 9, 8, 7, 6, 5, 4, 3, 2].
- 2. Compute the total sum of all products.
- 3. Compute remainder: Remainder = Sum % 11.
- 4. Compute check digit: CheckDigit = 11 - Remainder.
- 5. If CheckDigit == 11, final check digit is 0.
- 6. If CheckDigit == 10, the NHS number is INVALID by regulation and rejected.