Spanish DNI/NIE Letter Calculator Online: Free, Official

Compute the letter of your Spanish DNI or NIE with the official algorithm (modulo 23), or validate a full ID.

Calculate the letter of the Spanish DNI with the modulo-23 algorithm, including NIE numbers for foreigners (X, Y, Z). Check your ID is written correctly.

By VOV · Last updated: October 21, 2026

How it works

The letter is computed with the official modulo 23 operation: the number is divided by 23 and the remainder (0–22) indexes into «TRWAGMYFPDXBNJZSQVHLCKE». For NIE, the leading letter is first converted (X→0, Y→1, Z→2). The calculation is instant and 100% local.

Use cases

Frequently asked questions

How is the DNI letter computed?

The 8-digit number is divided by 23 and the remainder (0–22) is looked up in the official table TRWAGMYFPDXBNJZSQVHLCKE.

What about the NIE letter?

The initial letter is replaced by a number (X→0, Y→1, Z→2) and the same modulo 23 is applied to the resulting 8-digit number.

Does the letter distinguish people?

Yes: number + letter uniquely identify each citizen. Two people never share the same DNI.

What if my letter doesn't match the one on my DNI?

Double-check that you typed the 8 digits correctly, with no spaces or extra zeros. If the number is right and the letter differs, the physical document prevails: it may be a printing error to fix at the police station.

Is the DNI letter mandatory for official procedures?

Yes, the full DNI always includes the letter: forms, contracts and banking procedures require it. Without the letter the document counts as incomplete and many systems reject it automatically.

Related tools