NIF, NIE, DNI and CIF Validator (Spain)

Paste DNI, NIE or company NIF numbers to check them and see the expected letter when wrong.

Runs in your browser. Your files never leave your device. See how to check

…

How to do it

  1. 1
    Paste numbers

    One NIF, NIE or company NIF per line.

  2. 2
    Read the results

    Valid or not with the type.

  3. 3
    Fix errors

    See the expected letter or digit.

  4. 4
    Export

    Download the results.

About this tool

Every person and company in Spain has a tax identification number, the NIF. For Spanish citizens it is the DNI number with a control letter; for foreigners it is the NIE, which starts with X, Y or Z; for companies and other entities it starts with a letter indicating the type of entity and ends with a control digit or letter (the former CIF). Each includes a check that catches most typing errors. This validator checks them in batch.

Who this is for

Accountants, HR teams, landlords, developers of forms and anyone handling Spanish IDs.

DNI and NIF of individuals

The DNI has 8 digits and a letter. The letter is the remainder of the number divided by 23, mapped to the sequence TRWAGMYFPDXBNJZSQVHLCKE. For example, 12345678 mod 23 = 14, which gives Z.

NIE of foreigners

The NIE has a letter X, Y or Z, 7 digits and a control letter. For the check, X becomes 0, Y 1 and Z 2, then the same mod 23 rule applies. NIEs starting with Y and Z were introduced when X numbers ran out.

K, L and M

Special NIFs start with K (Spaniards under 14 without DNI), L (Spaniards living abroad without DNI) or M (foreigners without NIE). They use the same letter rule on the 7 digits.

Company NIF (CIF)

Companies and entities have a letter indicating their type (A for public limited companies, B for limited companies, G for associations, P for local authorities, Q for public bodies, and others), 7 digits and a control character. The control is calculated by adding the digits in even positions and the digits of twice each odd-position digit; the control digit is 10 minus the last digit of the total. Some types must use a letter (P, Q, R, S, N, W), others a digit (A, B, E, H), the rest either.

What the check proves

A correct letter or digit shows the number is consistent. It does not prove that it belongs to a real person or company. For VAT purposes, the AEAT census can be checked, and for EU operations, VIES with the ES prefix.

Batch use

Paste a list, one per line. Spaces, dots and dashes are ignored. Wrong lines show the expected letter or digit.

Data protection

DNI numbers are personal data. Use them only for legitimate purposes and protect lists you process.

Where the numbers appear

The DNI number is printed on the identity card, the NIE on the foreigner's certificate or TIE card, and the company NIF on the tax registration certificate and invoices.

Worked example

12345678Z is a valid DNI-format NIF. 12345678A is wrong: the expected letter is Z. X1234567L is a valid NIE. B12345674 is a valid company NIF format for a limited company.

Limits

A format and control check, not an official confirmation of identity.

Worked example

12345678Z is valid; 12345678A is wrong and should end in Z.

Quick facts

Frequently asked questions

How is the DNI letter calculated?

The number mod 23, mapped to TRWAGMYFPDXBNJZSQVHLCKE.

How do I check an NIE?

Replace X, Y, Z with 0, 1, 2 and apply the same rule.

What is a CIF?

The former name of the NIF of companies, with a type letter and a control character.

Does a valid NIF mean the person exists?

No, it only shows the number is consistent.

Can I check many numbers at once?

Yes, paste one per line.

Is my data stored?

No. It stays in your browser.

Guides for this tool

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages