Pular para o conteúdo
Tool

DNI/NIE Validator (Spain)

Check online, for free, whether a Spanish DNI or NIE has the correct control letter.

This validation checks only the DNI/NIE's control letter. It does not query the Dirección General de la Policía's database and does not indicate whether the document exists or who it belongs to.

The DNI/NIE Validator checks whether a Spanish identity document has the correct final letter, using the official modulo-23 algorithm.

What it is

Both the DNI (8 digits + letter) and the NIE (X/Y/Z + 7 digits + letter) end in a letter computed from the number, using the fixed table TRWAGMYFPDXBNJZSQVHLCKE. The tool automatically detects which of the two formats you pasted and applies the correct calculation.

Note: the validation is purely mathematical. It does not query the Dirección General de la Policía's database, so it can't confirm whether the document really exists or who it belongs to.

Who it's for

  • Developers and QA validating Spanish customer registrations.
  • HR and finance teams quickly checking a number before proceeding with a process.

How the calculation works

For a DNI, the tool divides the 8-digit number by 23 and compares the remainder (used as an index into the 23-letter table) against the typed letter. For a NIE, it first converts the initial letter (X→0, Y→1, Z→2), builds the full number, and does the same calculation. If the letter matches, the document is valid.

How to use it

Paste the DNI or NIE into the field and click Validate. To generate valid test documents, use the DNI/NIE Generator.

Worked example

Paste 12345678Z into the field above. The tool detects it doesn't start with X, Y, or Z, so it treats it as a DNI: divides 12345678 by 23, uses the remainder as an index into the 23-letter table, and compares it against the typed Z. If they match, it shows "Valid document".

Frequently asked questions

Does the tool detect on its own whether it's DNI or NIE?

Yes. If the text starts with X, Y, or Z, it's treated as a NIE; otherwise, as a DNI. In both cases the correct modulo-23 table for that format is applied.

Why does the letter come out wrong even though the number exists?

The control letter depends purely on the math of the number — if it doesn't match, it's usually a typo in one of the digits or in the letter itself.

Does this confirm the person exists in the Spanish registry?

No. The tool only checks the letter's math. Confirming real existence requires querying an official system, which this tool doesn't do.

About this content

Written by:
Ferramenta Grátis

Related tools