calculator dni

DNI / NIE Calculator

Use this tool to calculate the correct DNI letter from a number and validate complete DNI or NIE values.


Enter a value and click a button to see your result.

What is a DNI calculator?

A DNI calculator is a simple tool that helps you determine the control letter of a Spanish DNI (Documento Nacional de Identidad). The letter is not random—it is generated by a fixed algorithm. This makes it possible to verify whether a DNI is likely valid before using it in forms, internal records, onboarding workflows, or customer support checks.

How the DNI letter is calculated

The rule is straightforward: take the numeric part of the DNI, divide it by 23, and use the remainder to select a letter from this sequence:

TRWAGMYFPDXBNJZSQVHLCKE

  • Step 1: Get the DNI number (for example, 12345678).
  • Step 2: Compute 12345678 % 23.
  • Step 3: Use the resulting index to look up the letter in the sequence above.

If the computed letter matches the one provided, the DNI format is considered valid according to the official check-letter method.

DNI vs NIE: what is the difference?

A DNI is used by Spanish citizens. An NIE (Número de Identidad de Extranjero) is used by foreign residents and starts with X, Y, or Z. To validate an NIE with the same control-letter system:

  • Replace X with 0
  • Replace Y with 1
  • Replace Z with 2

Then apply the exact same modulo-23 process and compare with the final letter.

Why this calculator is useful

1) Cleaner data entry

Typos in identity fields are common. Automatic validation catches many errors instantly and improves data quality.

2) Better user experience

Users can fix mistakes right away instead of waiting for a failed submission later in the process.

3) Reduced manual rework

Admin teams spend less time correcting records when basic checks are done at the point of entry.

Common mistakes this tool helps detect

  • Wrong control letter for an otherwise correct number
  • Typing spaces or hyphens in inconsistent places
  • Confusing NIE prefix rules (X/Y/Z conversion)
  • Submitting values with incorrect length

Important note about validation

This calculator checks the mathematical control-letter logic only. It does not confirm legal ownership, issuance status, or whether a document is active in government databases. Treat it as a format and checksum tool, not as legal proof of identity.

Quick FAQ

Can I enter lowercase letters?

Yes. The calculator automatically normalizes to uppercase before validation.

Does it support NIE values?

Yes. It validates formats like X1234567L, Y1234567X, and Z1234567R.

Can this be used in a web form?

Absolutely. The same logic can be integrated client-side or server-side to improve registration and verification flows.

🔗 Related Calculators

🔗 Related Calculators