How to use
- 1Enter the 8 digits of a DNI, or an NIE with its initial X, Y or Z.
- 2Get the check letter instantly, together with the remainder used.
- 3To validate, paste the full DNI or NIE including its letter.
- 4Company CIFs and special NIFs (K, L, M) are detected automatically; put one per line to check several.
How the DNI letter is calculated
The DNI is the national identity number of Spanish citizens: 8 digits followed by a letter. Divide the number by 23 and look up the remainder (0–22) in the sequence TRWAGMYFPDXBNJZSQVHLCKE: remainder 0 gives T, 1 gives R, 2 gives W, and so on. The letters I, Ñ, O and U are not used to avoid confusion. The formula is public and catches most typing errors.
The NIE for foreigners in Spain
The NIE (Número de Identidad de Extranjero) is the number Spain assigns to foreigners who live, work, buy property or open a bank account there. It starts with X, Y or Z, followed by 7 digits and a check letter. To calculate the letter, replace X with 0, Y with 1 or Z with 2 and apply the same mod-23 table — Y1234567 is calculated on 11234567. Expats, digital nomads and anyone filling in Spanish forms can use it to double-check their own number.
CIF checks and what is not verified
Enter a company CIF (letter + 7 digits + check character) in the same field and the tool recognises it, verifies the check digit or letter and shows the entity type, such as S.A., S.L. or association. Only the formula is checked: the tool does not consult any database or confirm that a document exists or who it belongs to. Everything is calculated in your browser, which makes it useful for forms, spreadsheets and software testing.
Frequently asked questions
How do I calculate the letter of a DNI?
Divide the number by 23 and find the remainder in TRWAGMYFPDXBNJZSQVHLCKE: 0 = T, 1 = R, 2 = W, and so on.
How do I calculate an NIE letter?
Replace X with 0, Y with 1 or Z with 2, divide the resulting number by 23 and use the same table as for the DNI.
If the letter is correct, does the DNI exist?
Not necessarily. It only means number and letter are consistent; whether the document exists cannot be checked with the formula.
Is my DNI sent to a server?
No. The calculation is done entirely in your browser.
Not happy with the results?
Talk to Webin Agency about fast, SEO-friendly websites, e-commerce and Google Ads management.