Iranian national ID validator
Type a 10-digit Iranian national ID to see whether its structure and check digit are valid; the calculation is shown digit by digit. To clean long lists, paste a column of codes from Excel. Codes are checked only in your own browser and are never sent to a server.
Check a national ID
Only in your browser; nothing is sent
Persian or English digits; spaces and dashes are ignored.
Type a 10-digit code to see the checking steps.
Structure of the national ID: what each digit means
The national ID has ten digits in three parts:
- First three digits: the place-of-issue code, i.e. the county or office where the code was issued.
- Next six digits: the person's unique number within that office.
- Tenth digit: a check digit calculated from the first nine, which exposes typos.
The place-of-issue code is not necessarily the place of birth or residence; it is where the code was issued. So you cannot reliably infer someone's city from the first three digits, and this tool does not try.
National ID check-digit algorithm
Multiply by the weights
Multiply the first nine digits, from the left, by 10, 9, 8, 7, 6, 5, 4, 3 and 2.
Add the products
Add the nine products together.
Remainder mod 11
Take the remainder of that sum divided by 11.
Compare with the tenth digit
If the remainder is less than 2, the tenth digit must equal the remainder; otherwise it must equal 11 minus the remainder.
Example: code 0012345679
0×10 + 0×9 + 1×8 + 2×7 + 3×6 + 4×5 + 5×4 + 6×3 + 7×2 = 112Weighted sum of the first nine digits112 mod 11 = 2Remainder mod 1111 − 2 = 9The remainder is 2 or more, so the check digit is 9 and the code is valid
Only about one in ten random 10-digit numbers passes this test. Most single-digit typos and swaps of two adjacent digits also break the check digit. Still, a valid code only means the structure is correct, not that the code actually belongs to someone.
This check does not verify identity. A code that is valid here may belong to nobody or to someone else. Matching a national ID with a name or mobile number is only possible through an official inquiry service.
What does a national ID starting with zero mean?
Many people's national IDs, including most of those issued in Tehran, start with a zero and sometimes two. These zeros are part of the place-of-issue code, and a code with leading zeros is just as valid as any other.
Trouble starts when the national ID is treated as a number. Excel strips leading zeros and shows 0012345679 as 12345679; the code becomes eight digits and fails every check. This tool pads eight- and nine-digit codes with zeros and warns you, because that is almost always what happened to them.
To prevent it, set the column format to Text in Excel before entering the codes (Format Cells, then Text). If the codes are already damaged, restore them to ten digits with =TEXT(A2,"0000000000").
Common mistakes in designing a national ID field are explained in the post What does a national ID starting with zero mean? Validating it correctly in forms.
Bulk-checking national IDs
If you have a registration list, a payroll sheet or a form export, copy the national ID column from Excel and paste it into Bulk check. Each line is checked separately and the line order, including empty lines, is preserved. Copy the result column and paste it next to the original column in Excel to filter the problem rows. Duplicate codes are counted separately.
Get the national ID right from the start
The best place to check a national ID is the moment it is entered, not weeks later in Excel. The National ID field in Porsino's form builder runs this same algorithm while the form is being filled in:
- It accepts Persian and Arabic digits and stores them in a single format.
- It keeps the code as text, so the leading zero is never lost.
- It rejects an invalid code before submission, and the same check runs again on the server so it cannot be bypassed by tampering with the browser.
- If each person may respond only once, set "One response per code" to the national ID question in the share settings, so the same code cannot be submitted twice from any device.
To build a registration form with a national ID, see Online registration form for details.
Frequently asked questions
Does a valid national ID mean a real one?
No. This check only shows that the code's structure and check digit are correct. A code can be valid yet belong to nobody, or to someone else. Matching a code to a person's identity is only possible through an official inquiry.
Why is a code like 1111111111 invalid?
A code whose ten digits are all the same passes the check-digit calculation, but it is almost always fake: it is what people type to get past a field. That is why most systems, including this tool, reject it separately.
My national ID has eight digits; what went wrong?
A national ID always has ten digits. An eight- or nine-digit code is almost always one whose leading zeros were stripped by Excel or another program. Add the zeros back at the start; this tool does that automatically and warns you.
Can you tell the city from the national ID?
The first three digits are the place-of-issue code, not the place of birth or residence. The lists of these codes circulating online are incomplete or outdated, so this tool does not guess the city.
Are the codes I enter stored?
No. The check runs in JavaScript on this page and no request goes to a server; the tool keeps working even if you disconnect from the internet after the page has loaded.
Does it check company national IDs too?
No. The national ID of legal entities has eleven digits and a different check algorithm. This tool only checks the ten-digit national ID of individuals.
Related pages
- Online registration formClass and conference registration with payment, capacity limits and tracking codes.
- Online form builderAny form with 62 field types, conditional logic, special themes and live reports.
- Number to wordsNumbers and amounts in Persian words; rials and tomans for cheques and contracts.
- Google Forms alternativeA fair comparison of Porsino and Google Forms for Iranian users.
Form-building guides
All posts- Iranian National ID in Forms: Why Checking for '10 Digits' Isn't EnoughIran's 10-digit national ID has a check digit. If your form only checks the length, 90% of made-up numbers slip through the filter.3 min read
- Jalali (Persian) Dates in Online Forms: Three Mistakes That Corrupt Your DataThe Jalali calendar is not just a different way of displaying dates. If you do the conversion in the wrong place, your reports end up shifted by a day.2 min read
- Why Users Abandon Forms Halfway (and How to Stop It)Form abandonment has less to do with 'impatient users' than with how many fields you ask for, the order of your questions, and where you show errors.3 min read
A form that won't accept a wrong national ID
Porsino's National ID field checks the check digit while the form is being filled in, accepts Persian digits and keeps the leading zero. Build your registration form for free.