Spain NIF / NIE / DNI Validator

Check the control letter of a Spanish DNI, NIE or NIF instantly.

Ad placeholder (leaderboard)
Enjoying the tools? Go Pro for £4.99 (one-time) and remove all ads — forever, on this device. Remove ads — £4.99

Spain’s personal tax and identity numbers all share a 9-character format with a final control letter: the DNI for citizens, the NIE for foreigners, and the NIF (which, for an individual, is simply their DNI or NIE). This validator detects the document type automatically and confirms whether the control letter is correct.

How it works

The control letter is a single modulo-23 checksum:

  1. Get the numeric part. A DNI uses its 8 digits directly. A NIE first maps its leading letter — X → 0, Y → 1, Z → 2 — and prepends that to the following 7 digits to form an 8-digit number.
  2. Take modulo 23. Compute number mod 23, giving a remainder from 0 to 22.
  3. Look up the letter. Index into the table TRWAGMYFPDXBNJZSQVHLCKE. The letter at that position must equal the document’s final character.

The letters I, O, U and Ñ are intentionally absent to avoid confusion with digits and similar-looking characters.

Example

For DNI number 12345678:

  • 12,345,678 mod 23 = 14
  • Position 14 in TRWAGMYFPDXBNJZSQVHLCKE is Z

So the valid DNI is 12345678Z. For the NIE X1234567, the X becomes 0 giving 01234567, then 01234567 mod 23 = 10, which maps to L, so X1234567L is valid.

TypeFormatExample
DNI8 digits + letter12345678Z
NIEX/Y/Z + 7 digits + letterX1234567L

It runs entirely in your browser, so the ID number you type is never uploaded. A structurally valid number is not guaranteed to be one that has actually been issued.

Ad placeholder (rectangle)