Spanish ID generator and validator (NIF, NIE, CIF)

Generate test NIF, NIE and CIF numbers with a correct check character, validate a pasted document and compute its check character. Everything happens in your browser.

Generate NIF

Generated document
Press Generate to create a document

Generate NIE

Generated document
Press Generate to create a document

Generate CIF

Generated document
Press Generate to create a document

Validate document

NIF/NIE check character

CIF check character

Generated documents are test data: they do not belong to real people or companies, although one may match by chance. The validator checks structure and check character, not that the document exists.

Nothing is stored or sent to any server.

Spanish tax identification documents end with a check character calculated from the rest of the number. In a DNI or NIE it is a letter obtained by dividing the number by 23, and in a company CIF it is a digit or a letter depending on the type of company. This tool generates test NIF, NIE and CIF numbers with the correct check character, validates a pasted document and tells you its type or the exact reason it fails, and computes the check character from the first eight characters. Generated documents are test data and do not belong to real people or companies. Everything is calculated in your browser, so nothing you type is sent or stored anywhere.

How to use it

  1. Pick the document type and click Generate in the NIF, NIE or CIF panel, then use Copy to take the result.
  2. To check a document, paste it in the Validate document panel and press Validate or Enter: spaces, hyphens and lowercase are accepted.
  3. If it is valid you see its type and breakdown; if not, you see the reason: format, length, unknown type or wrong check character.
  4. To complete a document, type its first eight characters in the NIF/NIE or CIF calculator and copy the result.

Frequently asked questions

How is the DNI letter calculated?
The eight-digit number is divided by 23 and the remainder picks the letter from the table TRWAGMYFPDXBNJZSQVHLCKE. For a NIE, the X, Y or Z is first replaced by 0, 1 or 2.
Why do some CIF numbers end in a letter and others in a digit?
It depends on the company type: types N, P, Q, R, S and W use a letter, A, B, E and H use a digit, and the rest accept either.
Are the generated documents real?
No, they are test data with a valid structure. One may match a real document by chance, so do not use them to impersonate anyone.
Is my data sent to a server?
No. Everything is calculated in your browser with no network requests, and nothing is stored or added to the URL.

Related tools