calcula dni

DNI Letter Calculator

Enter the numeric part of a Spanish DNI to calculate its control letter instantly.

You can type 1 to 8 digits. The tool will keep leading zeros automatically.


Verify a complete DNI

How to calculate a DNI letter correctly

If you need to calcula DNI quickly, the key is understanding that the Spanish DNI includes a control letter based on a simple mathematical rule. The number part is divided by 23, and the remainder points to one specific letter from a fixed sequence.

This calculator automates the process to avoid manual mistakes, especially useful when filling online forms, creating internal records, or validating data imports.

The official letter sequence

Spain uses this exact sequence for DNI letters: TRWAGMYFPDXBNJZSQVHLCKE

Formula: index = number % 23, then letter = sequence[index].

Step-by-step example

  • Take the numeric DNI: 12345678
  • Calculate the remainder: 12345678 % 23 = 14
  • Look at position 14 in the official sequence
  • Resulting letter: Z
  • Complete DNI: 12345678Z

Common errors when calculating DNI

1) Using the wrong letter table

Some websites publish outdated or incorrect letter lists. Always use the official 23-letter sequence shown above.

2) Ignoring leading zeros

A DNI like 00123456 is valid as a number format. Leading zeros can matter in display and storage contexts, so this tool preserves them for output.

3) Manual arithmetic mistakes

Doing modulo calculations by hand is error-prone under pressure. A dedicated calculator gives consistent, instant results.

DNI vs NIE: quick clarification

This page is focused on classic DNI numbers. NIE documents for foreign residents use a different initial character rule (X, Y, Z mapped to digits) before applying a related control-letter algorithm. If you are validating NIE, use a calculator built specifically for NIE logic.

Best practices for developers and admin teams

  • Validate format on input: digits + final letter for complete DNI.
  • Normalize to uppercase before checking letters.
  • Store the original value for audit, but process a normalized version for validation.
  • Never use DNI as a password or as the only identity factor.

Frequently asked questions

Can two people have the same DNI letter?

Yes. The letter depends on modulo 23, so many numbers share the same letter.

Is the DNI letter random?

No. It is deterministic and always derived from the numeric part.

Can I calculate DNI offline?

Yes. The algorithm is lightweight and can run in any browser without external libraries. This page does it directly with client-side JavaScript.

Final note

Use the calculator above whenever you need to generate or verify a DNI quickly and accurately. It is simple, fast, and designed to prevent the most common formatting and validation mistakes.

🔗 Related Calculators