The DNI/NIE Validator checks whether a Spanish identity document has the correct final letter, using the official modulo-23 algorithm.
What it is
Both the DNI (8 digits + letter) and the NIE (X/Y/Z + 7 digits + letter) end in a letter computed from the number, using the fixed table TRWAGMYFPDXBNJZSQVHLCKE. The tool automatically detects which of the two formats you pasted and applies the correct calculation.
Note: the validation is purely mathematical. It does not query the Dirección General de la Policía's database, so it can't confirm whether the document really exists or who it belongs to.
Who it's for
- Developers and QA validating Spanish customer registrations.
- HR and finance teams quickly checking a number before proceeding with a process.
How the calculation works
For a DNI, the tool divides the 8-digit number by 23 and compares the remainder (used as an index into the 23-letter table) against the typed letter. For a NIE, it first converts the initial letter (X→0, Y→1, Z→2), builds the full number, and does the same calculation. If the letter matches, the document is valid.
How to use it
Paste the DNI or NIE into the field and click Validate. To generate valid test documents, use the DNI/NIE Generator.
Worked example
Paste 12345678Z into the field above. The tool detects it doesn't start with X, Y, or Z, so it treats it as a DNI: divides 12345678 by 23, uses the remainder as an index into the 23-letter table, and compares it against the typed Z. If they match, it shows "Valid document".