Spain NIE Validator
Online validator for Spanish NIE numbers. Verifies structure, prefix, and check letter integrity.
How does Spain NIE validation work?
The validator removes punctuation, confirms the structure (prefix X, Y, or Z + 7 digits + 1 letter), and calculates the Modulo 23 checksum.
The prefix letter is converted to its numerical value (X=0, Y=1, Z=2) to form an 8-digit base, and the remainder modulo 23 is matched against TRWAGMYFPDXBNJZSQVHLCKE.
Anatomy & Structure of Spanish NIE
The Foreigner Identity Number (NIE) consists of 9 alphanumeric characters:
| Position | Field | Length | Meaning & Rule | Example |
|---|---|---|---|---|
| 1 | Initial Letter | 1 letter | Chronological resident series: X (value 0), Y (value 1), or Z (value 2) | Y |
| 2 to 8 | Sequential | 7 digits | Sequential file number in Central Foreigners Registry | 1234567 |
| 9 | Control Letter | 1 letter | Letter calculated with Modulo 23 on the 8-digit substituted number | B |
NIE Validation Algorithm (Modulo 23 with X/Y/Z Mapping)
Validation converts the initial letter to a numeric digit before applying modulo 23:
Letter = "TRWAGMYFPDXBNJZSQVHLCKE"[(Map(Letter) + 7_digits) % 23]
- 1. Replace initial letter with numeric prefix: X = 0, Y = 1, Z = 2.
- 2. Prepend prefix to the 7 numeric digits, creating an 8-digit integer.
- 3. Compute integer remainder: Remainder = Number % 23.
- 4. Lookup character in TRWAGMYFPDXBNJZSQVHLCKE.
- 5. Verify match with the 9th character.