DNI Generator
GeneratorsGenerate valid Spanish DNI numbers for testing
XXXXXXXXL
Click 'Generate' to create your first XXXXXXXXL
About this tool
About DNI Generator
The Spanish DNI (Documento Nacional de Identidad) is the national identity document issued to Spanish citizens. It consists of 8 digits followed by a single check letter, computed deterministically using Mod 23 arithmetic. This generator produces format-valid DNI numbers for testing purposes — they pass the check letter algorithm but are not registered with the Spanish authorities.
Every generated DNI follows the official Mod 23 algorithm: the 8-digit body is taken modulo 23, and the result maps to the check letter table 'TRWAGMYFPDXBNJZSQVHLCKE'. The same algorithm applies to NIE numbers (for foreign nationals) after substituting the X/Y/Z prefix with 0/1/2 before the modulus operation.
Ideal for testing Spanish-market applications: e-commerce checkout flows that collect DNI, government portal integrations, tax software, KYC pipelines, and any form that validates Spanish identity documents. Use it to populate test databases and staging environments without risking exposure of real personal data.
Generated DNIs pass the official check letter validation used by Spanish applications and government systems. The numbers are entirely fictitious — no real person is associated with them. All generation happens in the browser with no network requests.
Key Features
- Official Mod 23 check letter algorithm
- 8-digit body + check letter format
- Cryptographically random digit sequence
- Passes all format-level DNI validators
- 100% browser-based, no data sent
- For testing purposes only
FAQ
DNI Generator — Frequently Asked Questions
Can I use a generated DNI for official purposes?
No. Generated DNIs pass the Mod 23 check letter algorithm but are not registered with the Spanish Ministry of Interior (Dirección General de la Policía). They cannot be used for any official government transaction, identification, or legal document. These numbers are strictly for software testing and development.
What is the check letter algorithm?
The check letter is the 23rd character (0-indexed) in the string 'TRWAGMYFPDXBNJZSQVHLCKE', selected by taking the 8-digit number modulo 23. For example, 12345678 % 23 = 14, so the check letter is 'Z' (the letter at index 14). This single-line algorithm makes DNI validation one of the simplest in Europe.
What is the difference between DNI and NIE?
DNI (Documento Nacional de Identidad) is issued to Spanish citizens. NIE (Número de Identificación de Extranjero) is issued to foreign nationals residing in or with tax obligations in Spain. NIE starts with X, Y, or Z (representing 0, 1, 2) followed by 7 digits and the same Mod 23 check letter. Both use the same check letter table.
Are all 8-digit numbers valid for DNI?
Structurally, any 8-digit number from 00000000 to 99999999 can be combined with its corresponding check letter to form a format-valid DNI. In practice, the Spanish authorities only issue DNIs in specific ranges, and some ranges are reserved for testing (similar to SSN in the US). For development purposes, any 8-digit number + correct letter is considered valid.
Tips
- Use the DNI Validator page to verify a DNI or NIE number
- The same Mod 23 table works for NIE — just replace X→0, Y→1, Z→2 first
- Never test with real DNI numbers; use generated ones to protect privacy
- Copy All outputs one DNI per line, ready to paste into test data scripts