Spanish DNI & NIE letter
Calculate the letter of any document, validate a complete one, or generate test IDs.
100% in your browser — nothing is sent to any serverCalculate the letter
Without the final letter. For NIE, start with X, Y or Z.
Validate a complete document
Generate a test document
Generated documents are mathematically valid but random: they are meant for development and testing. Do not use them to impersonate identities or for fraudulent purposes.
How the DNI letter is calculated
The DNI letter is not random: it is a checksum obtained by dividing the document number by 23 and taking the remainder. That remainder (0 to 22) maps to a letter using the official table:
TRWAGMYFPDXBNJZSQVHLCKE
For example, for the number 12345678: 12345678 ÷ 23 leaves remainder 14, and position 14 in the table is Z. Result: 12345678Z.
What about the NIE?
The NIE uses the same algorithm, but the initial letter is first replaced by a number: X = 0, Y = 1, Z = 2. So the NIE Y1234567 is calculated as if it were the number 11234567.
Frequently asked questions
How is the DNI letter calculated?
The letter is obtained by dividing the document number by 23 and taking the remainder. That remainder (0 to 22) maps to a letter using the official table TRWAGMYFPDXBNJZSQVHLCKE. For example, the number 12345678 leaves a remainder of 14, which corresponds to Z.
Does it work with the NIE too?
Yes. The NIE uses the same algorithm, but first the initial letter is replaced by a number: X = 0, Y = 1 and Z = 2. So a NIE like Y1234567 is calculated as the number 11234567.
Are the generated documents real?
They are mathematically valid (the letter is correct) but random. They are meant for development and testing; they do not belong to real people. Do not use them for fraudulent purposes.
Is my ID number sent to any server?
No. All calculation happens in your browser. The number you type is never sent, never stored, and never leaves your device.