Spanish NIE number generator (X, Y, Z with check letter)
A valid NIE (Spain's foreigner identity number) has an X, Y or Z prefix, 7 digits and a check letter. To calculate the letter, the prefix is replaced with 0, 1 or 2 and the DNI's mod 23 rule is applied. NIEs generated by DataMockSeed are fake: they pass validation, but identify no real foreign resident.
The NIE replaces the X, Y or Z prefix with 0, 1 or 2 and applies the same mod 23 calculation as the DNI to get the check letter.
How it's calculated
X/Y/Z prefix (equivalent to 0/1/2) + 7 digits + check letter, same calculation as the DNI.
The X/Y/Z prefix is replaced by 0/1/2 and the rest follows the same calculation as the DNI.
- 1Prefix → equivalent digitY → 1
- 2Full number (prefix + 7 digits)15506303
- 3Remainder of number ÷ 232
- 4Letter at the remainder's positionW
Frequently asked questions
What is the difference between the NIE and the DNI?
The NIE identifies foreign residents in Spain and has an X, Y or Z prefix before 7 digits; the DNI has 8 digits. The check letter of both is calculated with the same mod 23 rule.
Are the X, Y and Z prefixes equally common?
No. In real life, X and Y are much more common than Z. The NIE generator does not enforce that ratio and lets you pick any prefix from the full generator.
Can I use a generated NIE to sign up test users?
Yes. A generated NIE has the same format and check letter that a real form requires, without using the data of an existing person.
Keep exploring
Looking for more data types? Try the full generator.