Spain DNI Generator
Generate and format valid Spanish DNI (National Identity Card) numbers for development and testing.
About Spain DNI
The Documento Nacional de Identidad (DNI) is the official identity card issued by the Dirección General de la Policía (DGP) for Spanish citizens. For tax purposes (AEAT), the DNI number serves as the individual tax code (NIF).
The DNI consists of 8 digits followed by 1 control letter calculated via the official Modulo 23 algorithm with the 23-character table TRWAGMYFPDXBNJZSQVHLCKE.
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:
- 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.
Frequently Asked Questions (FAQ)
What is the structure of the Spanish DNI?
The DNI consists of 8 sequential numbers followed by 1 control letter (e.g., 12345678Z or 12345678-Z).
Are the generated numbers real?
No. All numbers are fictitious and generated according to official DGP/AEAT mathematical specifications strictly for QA, development, and software testing.
How is the control letter calculated?
The 8-digit number is divided by 23, and the remainder maps directly to the character table TRWAGMYFPDXBNJZSQVHLCKE.