Skip to main content

Spain DNI Validator

Online validator for Spanish DNI numbers. Verifies format, structure, and check letter integrity.

How does Spain DNI validation work?

The validator strips punctuation, confirms the 8-digit + 1-letter structure, and calculates the Modulo 23 checksum.

The remainder of the division by 23 is matched against the canonical 23-letter table TRWAGMYFPDXBNJZSQVHLCKE established by the Spanish Ministry of Interior and AEAT.

Anatomy & Structure of Spanish DNI

The Documento Nacional de Identidad (DNI) consists of 9 standardized characters:

PositionFieldLengthMeaning & RuleExample
1 to 8Sequential Number8 digitsNumeric sequential ID issued by National Police Directorate (DGP)12345678
9Control Letter1 letterUppercase letter computed via Modulo 23 with TRWAGMYFPDXBNJZSQVHLCKE tableZ

DNI Validation Algorithm (Modulo 23)

The Spanish Police and AEAT calculate the control letter via integer division by 23:

Letter = "TRWAGMYFPDXBNJZSQVHLCKE"[Number % 23]
  1. 1. Extract the 8 numeric digits of the DNI.
  2. 2. Compute integer remainder: Remainder = Number % 23.
  3. 3. Index the official conversion string: TRWAGMYFPDXBNJZSQVHLCKE.
  4. 4. Confirm match with the 9th character.

Frequently Asked Questions