Recover the letter
If you only have the digits of a DNI, get the letter instantly.
Type the digits of a Spanish DNI to get its letter, or check whether a DNI, NIE or CIF is correct and what its check character should be. You can validate whole lists. Nothing leaves your browser.
Type the 8 digits of the DNI to calculate the letter, or the full document to check whether it is correct. There is no need to remove spaces or hyphens.
The 8 digits of a DNI, a full DNI or NIE, or a company CIF.
You will see the matching letter, whether the document is valid and, for a CIF, the type of entity.
In “Validate a list”, paste one document per line and copy the results table.
The letter of the Spanish DNI (national identity number) is a check character: the number is divided by 23 and the remainder (0 to 22) is replaced by a letter from the sequence TRWAGMYFPDXBNJZSQVHLCKE. For example, 12345678 divided by 23 leaves a remainder of 14, which corresponds to Z. It catches typing mistakes; it does not tell you whether the DNI exists.
The NIE starts with X, Y or Z, followed by 7 digits and a letter. To calculate the letter, X is replaced by 0, Y by 1 and Z by 2, and the same calculation as for the DNI is applied. Tax IDs starting with K, L or M (people without a DNI or NIE) follow the same rule.
The tax ID of a legal entity (the former CIF) has an initial letter that shows the type of entity, 7 digits and a check character, which can be a digit or a letter depending on the type. The most common letters are A (public limited company, S.A.), B (private limited company, S.L.), E (joint ownership), G (association), H (community of property owners) and J (civil partnership).
A valid document only means that the check character matches: it does not guarantee that it exists or who it belongs to. This tool does not generate document numbers.
How it works: for a DNI it divides the number by 23 and replaces the remainder (0 to 22) with the corresponding letter in the series TRWAGMYFPDXBNJZSQVHLCKE, as explained by the Spanish Ministry of the Interior. For an NIE it replaces the initial X, Y or Z with 0, 1 or 2 and applies the same calculation. For tax numbers (NIF) of individuals beginning with K, L or M it applies the same calculation to their 7 digits. For the NIF of companies and other entities (the former CIF), the initial letter shows the legal form under Order EHA/451/2008, and the check character is calculated with the commonly used algorithm, which that order does not set out.
Scope: Spanish identification documents (DNI, NIE and NIF).
Limits: a matching check character only means there are no obvious typing errors: it does not guarantee that the document exists or say who it belongs to, because the tool does not query any database. NIFs with M that contain letters (Royal Decree 1065/2007 allows seven alphanumeric characters) are accepted as a correct format, but their check character is not verified because there is no published official algorithm. Everything is calculated in your browser.
Last reviewed: · DNI and NIE letter algorithm, NIFs beginning with K, L and M, and legal form letters in company NIFs · Maintained by José Antonio Conesa Blázquez, owner of MicroSAS (Legal notice).
Indicative calculation: it applies the general rules of the sources cited and does not replace advice from a professional or information from the competent authority.
If you only have the digits of a DNI, get the letter instantly.
Verify a customer’s or supplier’s NIF or CIF before issuing an invoice.
Validate a whole column of DNI and NIE numbers copied from a spreadsheet.
The CIF letter tells you whether it is an S.A., an S.L., an association…
Divide the DNI number by 23 and keep the remainder. Each remainder matches a letter: 0 is T, 1 is R, 2 is W, 3 is A… The calculator does it for you.
No. It only means the letter is the right one for that number. To know whether a document is real you have to check with whoever issued it.
The DNI is the identity document of Spanish citizens; the NIE, the identity number of foreign nationals; and the NIF, the tax identification number. For individuals, the NIF is the same as the DNI or NIE.
Since 2008 it is also called NIF for companies, but the format is the same and many people still call it CIF.
No. Everything is calculated in your browser: no DNI or CIF is sent over the internet.