InputTestHub

DNI and NIE Validator

Checks a Spanish DNI or NIE letter, which is the number modulo 23 mapped onto a fixed 23-letter table.

Security Nothing uploaded No sign-up Free, unlimited
Security tool
Enter something above.
In short The letter on a Spanish DNI is not arbitrary and not a signature: it is the eight-digit number modulo 23, looked up in the fixed string TRWAGMYFPDXBNJZSQVHLCKE. Because 23 is prime and the table has no repeats, the letter catches every single-digit error and every transposition — 100% of both over 3,000 generated cases, the best detection rate in this family. A NIE works the same way with one extra step: the leading X, Y or Z counts as 0, 1 or 2 and is prepended to the seven digits before the modulo. Note the table deliberately omits I, Ñ, O and U, because they are too easily confused with 1, N, 0 and V. A correct letter proves the number was typed accurately, not that it was issued.

How to use the DNI and NIE Validator

  1. Paste the number — punctuation and spaces are ignored.
  2. Read the verdict and, where the number encodes anything, what it decodes to.
  3. Treat a pass as "typed correctly", not as "confirmed by the authority".

About the DNI and NIE Validator

The letter on a Spanish DNI is not arbitrary and not a signature: it is the eight-digit number modulo 23, looked up in the fixed string TRWAGMYFPDXBNJZSQVHLCKE. Because 23 is prime and the table has no repeats, the letter catches every single-digit error and every transposition — 100% of both over 3,000 generated cases, the best detection rate in this family. A NIE works the same way with one extra step: the leading X, Y or Z counts as 0, 1 or 2 and is prepended to the seven digits before the modulo. Note the table deliberately omits I, Ñ, O and U, because they are too easily confused with 1, N, 0 and V. A correct letter proves the number was typed accurately, not that it was issued.

What people use it for

  • Catching a mistyped number in a form before it reaches a database.
  • Cleaning an imported list and finding the rows that cannot be right.
  • Understanding what the number encodes and what it does not.

Details

RuleNumber mod 23, looked up in TRWAGMYFPDXBNJZSQVHLCKE
NIE prefixX counts as 0, Y as 1, Z as 2, prepended before the modulo
Typo detection100% of single-digit errors and 100% of transpositions
Missing lettersI, Ñ, O and U are excluded — too close to 1, N, 0 and V
PrivacyCalculated in your browser
Because the check is a modulo rather than a weighted sum, it is the strongest scheme here — every single-digit error and every transposition is caught, which weighted mod-10 schemes cannot promise. Nothing you paste is transmitted — the check runs entirely in your browser.

Where this tool stops

Confirms the letter matches the number. It cannot confirm the document exists, is current, or belongs to the bearer.

Frequently asked questions

Is the DNI letter random?
No — it is fully determined by the number. That is the point: it means a mistyped digit produces the wrong letter, which is caught immediately. It also means the letter carries no information of its own.
Why does the letter table skip I, O and U?
To avoid confusion with the digits 1 and 0 and with the letter V when handwritten or read aloud. Ñ is excluded for the same practical reason. Twenty-three letters remain, which is why the modulus is 23.
How is a NIE different from a DNI?
A NIE is issued to foreigners and starts with X, Y or Z. That letter is converted to 0, 1 or 2 and placed in front of the seven digits, then the same modulo-23 rule applies. Older NIEs begin with X, newer ones with Y and then Z as each series filled.
Is anything I paste sent anywhere?
No. The arithmetic runs in this browser tab and no request is made — open your Network tab and watch while you type. That matters more for an identity number than for almost anything else on this site, which is why there is no server side to this tool at all.
Does this replace an official check?
No, and it cannot. Every scheme here proves at most that the digits are internally consistent. Only the issuing authority can confirm a number exists, is active, and belongs to a particular person.
Is the DNI and NIE Validator free?
Free, unlimited, and no email address required. You can use it a hundred times a day and nothing changes.
Can you see what I put into this utility?
No. The DNI and NIE Validator runs entirely in your browser using JavaScript. Nothing is transmitted, logged or stored, which you can verify yourself in the Network tab of your browser's developer tools.
What problem does the DNI and NIE Validator solve?
The jobs it is built for: catching a mistyped number in a form before it reaches a database. Cleaning an imported list and finding the rows that cannot be right. Understanding what the number encodes and what it does not. It is built for exactly those cases rather than being a general-purpose tool with this bolted on.
Where does the DNI and NIE Validator stop being reliable?
Confirms the letter matches the number. It cannot confirm the document exists, is current, or belongs to the bearer. Knowing where a tool stops being trustworthy matters more than the cases where it works.
What are the key numbers for the DNI and NIE Validator?
Rule is Number mod 23, looked up in TRWAGMYFPDXBNJZSQVHLCKE. NIE prefix is X counts as 0, Y as 1, Z as 2, prepended before the modulo. Typo detection is 100% of single-digit errors and 100% of transpositions. These are printed on the page itself, so you do not have to take them on trust.
Is there an app version?
Yes. The page is responsive and the utility works in Chrome, Safari, Firefox, Edge and Samsung Internet on both Android and iOS. There is no app to install and nothing to sign into.

Related security tools

All 100
01

Password Strength Checker

Estimates password entropy and crack time, and identifies the specific weaknesses in what you…

02

Hash Generator

Generates MD5, SHA-1, SHA-256, SHA-384 and SHA-512 hashes of any text, all at once.

03

MD5 Hash Generator

Generates an MD5 hash of any text or string, with optional HMAC and uppercase output.

05

SHA-1 Hash Generator

Generates SHA-1 hashes, still required by some legacy systems and Git object addressing.

06

SHA-512 Hash Generator

Generates SHA-512 hashes for checksums, signatures and archival fingerprints. Runs in your…

09

AES Text Encryption

Encrypts and decrypts text with AES-GCM 256-bit using a password, entirely in your browser.

10

XOR Cipher Tool

Applies a repeating-key XOR to text or hex, the operation behind many simple obfuscation…