Skip to content

Calculate the DNI and NIE letter

Find the check letter of a Spanish DNI or NIE from its digits, or check that the letter of a full NIF is right; the calculation happens in your browser.

Document

DNI / NIFDocumento Nacional de Identidad

National identity and tax number · written like 12345678Z

Where the rules come from

Calculate the letter

Runs in your browser · no uploadHow it works

How to use DNI letter calculator

  1. 1

    Type the eight digits

    The page opens on the DNI letter calculator. Enter the number with or without dots; shorter old numbers are padded with zeros.

  2. 2

    Read the full NIF

    The number appears with its letter, ready to copy, together with a check that confirms it.

  3. 3

    Switch to NIE if needed

    For a foreign resident choose NIE and type X, Y or Z followed by seven digits.

  4. 4

    Check a list

    Paste DNIs or NIEs one per line on the Check tab to find every wrong or missing letter at once.

Limits and Pro

Free: one calculation as you type, and checks of up to 10,000 DNIs, NIEs or company NIFs pasted at once.

Pro hides the ads; the calculator has no limits to lift. See Pro

About DNI letter calculator

The letter at the end of a Spanish DNI is not chosen: it is the remainder of the eight-digit number divided by 23, looked up in the fixed sequence TRWAGMYFPDXBNJZSQVHLCKE. The Ministry of the Interior's own example is 12345678, whose remainder is 14 and whose letter is therefore Z. Because the letter depends on every digit, it catches every typo in a single digit, which is why banks, the tax agency and online forms reject a DNI with the wrong one.

Foreign residents' NIE numbers use the same table after replacing the leading X, Y or Z with 0, 1 or 2, so X1234567 is computed as 01234567. Only 23 letters can appear: I, O, U and Ñ never do.

This page opens on the calculator: type the digits of a DNI, with or without dots or a leading zero, and the full NIF appears with its letter. Switch the document to NIE to calculate a foreigner's number, or to the company NIF, which follows a different rule: a letter for the legal form, seven digits and a control character from a Luhn sum. The Check tab takes a whole column of DNIs pasted from a spreadsheet and marks every wrong letter with the one it should have been.

A correct letter only proves the number is consistent. Whether a DNI was actually issued, or to whom, is known only to the Policía Nacional, which this page never asks.

Privacy

The DNI and NIE digits you type are turned into letters by this page itself. Nothing is sent to any server or kept after you leave, so it is safe to use with real numbers from your own records.

DNI letter calculator: frequently asked questions

How is the DNI letter calculated?
Divide the eight-digit number by 23 and keep the remainder, which runs from 0 to 22. Look it up in the sequence T R W A G M Y F P D X B N J Z S Q V H L C K E: remainder 0 gives T, 1 gives R, and so on. For 12345678 the remainder is 14, so the letter is Z and the full NIF is 12345678Z.
How do I calculate the letter of an NIE?
Replace the first letter with a digit, X with 0, Y with 1 and Z with 2, so that the NIE becomes an eight-digit number, then apply the same remainder-of-23 table as for a DNI. Choose NIE in the document switch and type, for example, X1234567: the calculator returns the number with its letter, X1234567L.
Is the NIF the same thing as the DNI?
For Spanish citizens, yes: the tax number (NIF) is the DNI number with its letter. Foreign residents use their NIE as NIF. Companies and other entities have a different NIF that starts with a letter for the legal form, such as B for a sociedad limitada, and ends with a digit or letter calculated by another rule, which this page also checks.
Which letters can never appear at the end of a DNI?
The table has only 23 letters, so I, O, U and Ñ never appear as the check letter; a DNI ending in one of them is certainly mistyped. The calculator rejects those at once and names the letter the digits really call for, which usually reveals whether the mistake is in the letter or in one of the digits.
Can I check a whole spreadsheet column of DNIs?
Copy the column and paste it into the Check tab: each line is checked separately, up to 10,000 at a time, and blank lines are skipped. The summary counts valid and invalid entries, and you can copy only the valid ones or download every result, including the expected letter, as CSV or JSON.

Other tasks with this tool

All developer tools