Spanish NIF, NIE, CIF and IBAN validator and generator
Validate a Spanish NIF, NIE, CIF or IBAN: detects the type, says whether it is valid, why not (with the correct control letter) and formats it. Validates lists and generates valid test data for developers.
Validate one value
Valid · DNI / NIF
Formatted: 12345678Z
Validate a list
5 values, 4 valid.
| Value | Type | Result |
|---|---|---|
| 12345678Z | DNI / NIF | Valid |
| X1234567L | NIE | Valid |
| A58818501 | CIF | Valid |
| ES91 2100 0418 4502 0005 1332 | IBAN (ES) | Valid |
| 12345678A | DNI / NIF | The control character is wrong. It should be: Z. |
Test data generator
Test data: not real people or accounts.
Values are random and only satisfy the structure and control digits: they may coincide with real ones. Use them only in test environments.
How they are checked
DNI and NIE carry a control letter: the number modulo 23 indexes TRWAGMYFPDXBNJZSQVHLCKE (for a NIE, X, Y, Z count as 0, 1, 2). A CIF adds the digits in even positions and the digits of twice the odd ones; the control is the complement to 10, as a digit or letter depending on the entity type. A Spanish IBAN is checked with mod 97 and with the two account control digits. Everything is computed in your browser; nothing is sent anywhere.
How to use it
- Paste or type a NIF, NIE, CIF or IBAN into the field under "Validate one value". Spaces, dashes and lower case are fine.
- Read the verdict: Valid or Not valid, the detected type (DNI / NIF, NIE, CIF or IBAN) and the value in standard format. A wrong value shows why and, for a control letter, the correct one.
- For many values, paste them in "Validate a list", one per line (commas and semicolons also work), then use "Download results as CSV".
- Developers can open the Test data generator, pick a Type, choose the Count (1 to 50) and press Generate, then "Copy all".
Worked example
Type 12345678A. The tool detects a DNI and says Not valid: the control letter is wrong, and it should be Z. Why Z? 12345678 divided by 23 leaves 14, and position 14 in the table TRWAGMYFPDXBNJZSQVHLCKE is Z. Now try the NIE X1234567L: X counts as 0, so 01234567 leaves 19 and the letter is L, which is valid. The CIF B12345678 is a limited liability company (SL), but its control digit should be 4, so B12345674 passes. The IBAN ES91 2100 0418 4502 0005 1332 is valid; change its last digit to 1 and the mod 97 check digits are reported as 21.
Frequently asked questions
How is the letter of a DNI calculated?
Divide the eight-digit number by 23 and use the remainder to pick a letter from the fixed table TRWAGMYFPDXBNJZSQVHLCKE, where 0 is T and 22 is E. For example, 12345678 leaves 14, which is Z. The letter is only a check against typing errors, not a secret or a unique identifier on its own.
How does a NIE differ from a DNI?
A NIE starts with X, Y or Z, then seven digits and a control letter. To calculate the letter, X, Y and Z are replaced by 0, 1 and 2 and the same mod 23 table is used. So X1234567 becomes 01234567, which gives L. NIFs starting with K, L or M are for people without a DNI, such as some minors.
What does the first letter of a CIF mean?
It gives the entity type: A is a public limited company (SA), B a limited liability company (SL), G an association or foundation, P a local authority, and so on; the page shows the type next to the result. The control is a digit or a letter depending on that type, computed from the other seven digits.
Does a valid number mean it exists?
No. The tool checks structure and control characters only, the same arithmetic that catches typos. A value can pass and still not belong to anyone, and it cannot tell you whether a company or person is registered. For tax or invoicing purposes the official checks of the tax agency are what count.
How is a Spanish IBAN checked?
A Spanish IBAN has 24 characters: ES, two check digits and a 20-digit account number. The tool moves the first four characters to the end, turns letters into numbers and checks that the remainder modulo 97 is 1. It also checks the two control digits inside the account number. Nothing you type leaves your browser.
Everything is calculated in your browser: this site doesn't send what you type anywhere.