CALCULATE Electronic DNI Letter  ▷ Step by Step Guide ▷ 2020

One of the most useful documents we have is the electronic DNI or DNI-E, which is a digital version of the classic National Identity Document. However, many people do not have much idea of ​​how to use it and what advantages it has in taking the time to remove it since they think that it is something that only entrepreneurs and people related to them need. But they couldn’t be further from the truth.

One of the most important elements of this document is the letter, which is an alphabetical value that is located right at the end of the identification number. This is used as a checker to make sure that the number before it is true and correct, so it is not randomly placed. There are several ways to get this letter, which is determined by an algorithm in which the numerical value is divided by 23 and the result is replaced by a letter.

This is something that the authorities do when printing the physical document, but how is it done with the digital version? That is what you will learn in this tutorial where We are going to teach you how to get the letter of the Electronic DNI and we will educate you so that you know what this document is and why it is important that you have it and take advantage of all the benefits that come with it.

What is the electronic DNI and what advantages does it offer us in Spain?

electronic DNI parts

The DNI-E is the electronic version of the well-known National Identity Document that allows you to verify your identity when carrying out processes on the internet. In a way it works like a digital signature that allows you to carry out legal procedures with national organizations such as Treasury or Social Security, so you don’t have to move from the comfort of your home and wait for hours sitting in an office.

The advantages of this identification document are many since financial entities can check your data, which facilitates the exchange of information. One of the benefits of this technology is that you can access your bank account remotely, using as an identification element your digital trace represented in the fingerprint of your thumb.

Furthermore, this tool makes it easy for you to sign documents in PDF or Microsoft Word formats. By using it everyone knows that you were the person who carried out the procedure. With this, I want to tell you that the DNI guarantees your identity at all times, reducing the risks of fraud and encourages the use of electronic means, since technology is practically impenetrable.

To use this technology, you must install a program on your computer, which was developed for Windows, MacOS, and Linux operating systems. If by chance your platform is that of the “Manzanita” or “penguin” you must use an OpenDNIe application, to make it work, but in general it is very easy to use on all platforms. If you want activate or renew the Electronic DNI Click here.

Steps to check and calculate the letter of the DNI (National Identity Document) of a person

Calculate the letter of the DNI-E It is one of the easiest things to do, as we told you before, all you have to do is divide your identification number and, according to the rest, a letter is attributed to you.

These letters vary and are not in alphabetical order, but you can find out by using this table below:

  • If the rest is corresponds the letter T.
  • If the rest is 1 corresponds the letter R.
  • If the rest is 2 corresponds the letter W.
  • If the rest is 3 corresponds the letter a.
  • If the rest is 4 corresponds the letter G.
  • If the rest is 5 corresponds the letter M.
  • If the rest is 6 corresponds the letter Y.
  • If the rest is 7 corresponds the letter F.
  • If the rest is 8 corresponds the Letter p.
  • If the rest is 9 corresponds the letter D.
  • If the rest is 10 corresponds the letter X.
  • If the rest is eleven corresponds the Letter B.
  • If the rest is 12 corresponds the letter N.
  • If the rest is 13 corresponds the letter J.
  • If the rest is 14 corresponds the letter Z.
  • If the rest is fifteen corresponds the letters.
  • If the rest is 16 corresponds the letter Q.
  • If the rest is 17 corresponds the letter V.
  • If the rest is 18 corresponds the letter H.
  • If the rest is 19 corresponds the letter I.
  • If the rest is twenty corresponds the letter C.
  • If the rest is twenty-one corresponds the letter K.
  • If the rest is 22 corresponds the letter E.

And what about foreigners? Those expatriates residing in Spain have a NIF that is made up of a letter that can be X, Y or Z, a 7-digit number and a control code. The latter is determined in the same way as the letter of the DNI; dividing it by 23 and according to the result a unique code is determined.

Online tools

With this program you can calculate the letter of the DNI (National Identity Document) or the letter of the NIF (Tax Identification Number) yourself. So do the following:

  • Enter this website.
  • This information appears on the screen:


  • Write your DNI / NIF in the box and click “Calculate letter“.
  • Then he throws you your ID with your respective letter. That’s it.

The others online tools They are similar in their operation, we leave you the URLs so that you can visit them and perform the calculation in the one that seems best to you.


Excel Spreadsheet

The Excel Spreadsheet, from Microsoft Office, provides many functions, and it has one that facilitates the calculation of the DNI / NIF.

the procedure is the next:

  • It all starts in the modulo 23 function, which serves as an integer.
  • This gets like the rest; when performing the entire division of the DNI between the number 23.
  • When you use this Excel function, the result will range from 0 to 22.

The number 14 that is observed on the screen is said resultant in this case, then you must place the letters in the following order: TRWAGMYFPDXBNJZSQVHLCKE.

But… Why is this order followed and not all the letters of the alphabet?


  • The reason is that the lyrics were not incorporated I, O, Ñ and U. The first two is to avoid mistakes and confusion so that they are not interpreted as the numbers 1 and 0. In the case of letter Ñ it was not used because they are not used in other European countries, and in that of the letter U to avoid being compared with V.
  • As the result is 14 From the previous division, the process of counting spaces begins, for example for the DNI “12345678”His letter is Z.
  • You must start counting from 0, not from 1 and as a result you will have the correct order, which is Z, the fourteenth letter of the order that we gave you earlier.
  • I invite you to perform this example with the online tools that we show you above and check the result.

To apply all this in Excel you must do the following:

  • You must open the Excel sheet, to enter the formula.
  • Later you go to the cells and create a column for the DNI list and next to the column of numbers, create another for the result with the letter.


  • Then you are going to calculate the letter with this formula, remember you only have to use module 23 + the order of the letters.
  • What would leave you something like this:
  • What translated into the Spanish language means: “When calculating the rest of the whole division of cell A2 by 23, and adding one to it, and you must indicate the letter assigned to the DNI”.

Thanks to the functionalities of the Excel functions, which has between its rows the Residue, calculates directly, the rest of the entire division of the DNI / 23. Then keep in mind the +1, this is because Excel always starts from 1 and not from zero.

It would be as you see it in the following image:


  • Excel will allow you to concatenate the DNI and the letter, in a few words, you will join the numbers with the letter.
  • What you should do is write the following formula:

That will make everything display as follows:


Using a Mathematical Algorithm

To perform this procedure, you should have knowledge of algorithm and programming, in addition to having a development environment software for example Eclipse and Java Runtime Environment (JRE, Java Runtime) which allows you to encode. But don’t worry, I’ll give you the ready-made codes. What I want is for you to have ideas on how to perform the DNI / NFI calculation using another method.

  • You must keep in mind what you have learned in Excel. Regarding the procedure of using the formula. I remind you: “When calculating the rest of the entire division of cell A2 by 23, and adding one, and it must indicate the letter assigned to the DNI” or what is the same; EXTRACT (“TRWAGMYFPDXBNJZSQVHLCKE”; WASTE (A2; 23) +1; 1)
  • View the DNI letter table, this is what the algorithm will do, when executing the program.


  • Proceed to coding in JAVA language. The algorithm will do what the excel function did; calculate module 23 to your DNI number.
  • Then to get the letter: To do that, execute a String that will belong to the letters in order, so with a charAt (module) you can calculate the letter corresponding to the indicated position. Now I show you the java code that implements the calculation:


Do you remember to do this, you must have programming knowledge. You can go to a computer science institute or academy and have a certified computer scientist run the code. The result will be to list the DNI with its respective letter.

If you have any questions, leave them in the comments, we will answer you as soon as possible, and it will also be of great help to more members of the community. Thank you! 😉

You may be interested:

Rate this post

Leave a Comment