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 control letter. It accepts two formats, the DNI (8 numbers and a letter) and the NIE (X, Y or Z, 7 numbers and a letter), and detects on its own which one you pasted. The calculation runs in the browser.

Notice: the tool validates only the letter. It does not query the Ministerio del Interior or the Policía Nacional, so it does not say whether the document exists, is in force or belongs to anyone.

What the DNI and the NIE are, and which country

The DNI (Documento Nacional de Identidad) is the identity document of Spanish citizens. The NIE (Número de Identidad de Extranjero) is the number given to foreigners in Spain. This tool deals only with Spain: the "DNI" of other countries, such as Argentina and Peru, has its own format, without the Spanish control letter, and is not validated here.

The letter is a calculation, not a lottery

For the DNI, you divide the 8-digit number by 23 and use the remainder as a position in the sequence TRWAGMYFPDXBNJZSQVHLCKE, starting at zero:

Remainder and letter: 0 T, 1 R, 2 W, 3 A, 4 G, 5 M, 6 Y, 7 F, 8 P, 9 D, 10 X, 11 B, 12 N, 13 J, 14 Z, 15 S, 16 Q, 17 V, 18 H, 19 L, 20 C, 21 K, 22 E.

This is the table published by the Ministerio del Interior. Note that I, O and U never appear, nor does Ñ. A DNI ending in one of those letters is invalid by construction.

Worked examples

  • DNI 12345678. 12,345,678 ÷ 23 leaves remainder 14, and the letter at position 14 is Z. The correct document is 12345678Z.
  • NIE X1234567. First, the X becomes 0, which gives the number 01234567, or 1,234,567. Dividing by 23, the remainder is 19 and the letter is L: X1234567L.
  • NIE Y1234567. The Y becomes 1, giving 11,234,567. The remainder is 10 and the letter is X: Y1234567X.

What the tool does not check

  • Whether the number was issued. Any 8-digit sequence has a correct letter, and most were never assigned.
  • CIF and other formats. The tax number of companies (CIF) uses another calculation and is not accepted. Only DNI and NIE with X, Y or Z go in.
  • Document validity. An expired or cancelled document is still valid in the math.

Common invalid entries

  • Old 7-digit DNI. Someone with a short number must pad it with a zero on the left, so 1234567L becomes 01234567L. Without that, the tool rejects it for length.
  • Wrong or forgotten final letter.
  • I, O or U in place of the control letter.
  • A NIE starting with a letter other than X, Y or Z.

How to use

Paste the document, with or without a hyphen, and click Validate. To create fictitious documents for testing, use the Generator tab or the DNI/NIE Generator. Another identification document with a check digit is in the RUT Validator, from Chile.

Frequently asked questions

Why does the tool reject my 7-number DNI?

Because it requires 9 characters in total. Short numbers must be padded with zeros on the left, and the letter calculation does not change, since 01234567 and 1234567 give the same remainder when divided by 23.

Which letters never appear at the end of a DNI?

I, O, U and Ñ. The 23-letter table of the Ministerio del Interior excludes them, and the tool rejects a document ending in any of them.

How is the letter of a NIE like X1234567 calculated?

The X is replaced with 0 (Y with 1, Z with 2), the number 01234567 is built and divided by 23. The remainder is 19, which corresponds to the letter L, and the correct NIE is X1234567L.

Does this tool work for the DNI of Argentina or Peru?

No. The DNI of those countries has its own format and does not use the modulo 23 control letter. The tool validates only Spanish DNI and NIE.

Can I type the document with a hyphen or spaces?

Yes. Anything that is not a letter or number is ignored, and lowercase letters are converted. You can paste, for example, 12345678-Z.

Can a document that is valid here belong to someone who has died or lost validity?

Yes, the tool only checks the letter. It does not know whether the number was issued, is in force or was cancelled.

About this content

Written by:
Ferramenta Grátis

Related tools