Codes & data

Iranian national code checker

Check whether an Iranian national code is well formed: one code, or a whole list at a time.

This tool runs entirely inside your browser. No file or text is sent to any server.

How to use

  1. Type or paste the national code into the box. If you have several, put each on its own line. To just try the tool, press “Insert an example”.
  2. The result appears at once under the box: a green badge means the code is valid, a yellow one means it is not, with the reason.
  3. For several codes there is a row for every line. To find the mistakes in a long list, turn on “Show only the invalid codes”.

Notes on this tool

The tool checks three things: the code has 10 digits, the digits are not all the same, and the last digit (the check digit) matches the 9 before it.

Persian and Arabic digits are accepted, and spaces and hyphens between the digits are ignored, so “۰۱۲ ۳۴۵ ۶۷۸۹” is 0123456789. Any other character, such as a letter or a dot, counts as an error.

A code with fewer than 10 digits is not valid, but if zeros in front would make it valid, the tool says so next to the reason. It never corrects anything itself.

The tool does not make codes and, for a wrong code, does not say what the right digit would be; it only checks the code you have.

Up to 5000 lines are checked at once. Empty lines are skipped, and the number of each row is the number of your line.

Frequently asked questions

What does a valid national code mean? Does it belong to someone?
No. Valid means the structure of the code is right: it has 10 digits and the last one matches the rest. A great many codes have the right structure and were never given to anybody, so this tool cannot tell whether a code exists or whose it is; only an official source can answer that. What the tool is for is catching a typing mistake before you enter the code in a form.
My national code starts with a zero, but Excel drops it. Why?
Excel treats anything made only of digits as a number and throws away the zeros in front. Before pasting the codes, set the column to the “Text” format. If the zeros are already gone, this tool shows the codes that would become valid with zeros in front.
How is the last digit of a national code calculated?
The first nine digits are multiplied by 10, 9, 8 and so on down to 2, and added up; then the remainder of the sum divided by 11 is taken. If the remainder is 0 or 1, the last digit must be the remainder itself; otherwise it must be 11 minus the remainder. This catches a single mistyped digit almost always, but not always: out of about 60 single-digit mistakes, one gets past this check.
Why is {ltr:1111111111} not valid when the arithmetic works out?
It is true: all ten repeated-digit codes, from 0000000000 to 9999999999, fill the check digit correctly. But they are not real national codes and the validators in common use reject them, so this tool rejects them separately too.
Is the code I enter saved or sent anywhere?
No. The check happens entirely inside your browser; nothing is sent to a server and the codes are not stored. Close the page or press “Reset” and nothing of them is left.

Related tools