Spain DNI Validator
Online validator for Spanish DNI numbers. Verifies format, structure, and check letter integrity.
How does Spain DNI validation work?
The validator strips punctuation, confirms the 8-digit + 1-letter structure, and calculates the Modulo 23 checksum.
The remainder of the division by 23 is matched against the canonical 23-letter table TRWAGMYFPDXBNJZSQVHLCKE established by the Spanish Ministry of Interior and AEAT.
Anatomy & Structure of Spanish DNI
The Documento Nacional de Identidad (DNI) consists of 9 standardized characters:
| Position | Field | Length | Meaning & Rule | Example |
|---|---|---|---|---|
| 1 to 8 | Sequential Number | 8 digits | Numeric sequential ID issued by National Police Directorate (DGP) | 12345678 |
| 9 | Control Letter | 1 letter | Uppercase letter computed via Modulo 23 with TRWAGMYFPDXBNJZSQVHLCKE table | Z |
DNI Validation Algorithm (Modulo 23)
The Spanish Police and AEAT calculate the control letter via integer division by 23:
Letter = "TRWAGMYFPDXBNJZSQVHLCKE"[Number % 23]
- 1. Extract the 8 numeric digits of the DNI.
- 2. Compute integer remainder: Remainder = Number % 23.
- 3. Index the official conversion string: TRWAGMYFPDXBNJZSQVHLCKE.
- 4. Confirm match with the 9th character.