Validate Iranian National IDs (کد ملی) with optional city-prefix check, and generate valid synthetic IDs for fixtures.
The Iranian National ID (کد ملی) is a 10-digit code with a check digit and an embedded 3-digit city/registration prefix. Persian Tools provides validation, prefix lookup, and a generator family for tests.
Validate
verifyIranianNationalId(nationalId, options?)
import { verifyIranianNationalId } from "@persian-tools/persian-tools";verifyIranianNationalId("0499370899"); // trueverifyIranianNationalId("1234567890"); // false (checksum fails)verifyIranianNationalId(undefined); // undefined (falsy input)// Opt in to the extra city-prefix checkverifyIranianNationalId("0499370899", { checkPrefix: true });
interface VerifyIranianNationalIdOptions { checkPrefix: boolean; // required once you pass an options object}
Omit the second argument entirely to get the default, which leaves the prefix check off. There is no partial
options object: verifyIranianNationalId(id, {}) is a type error.
The prefix check is off by default as of v5 — it used to be on. The mod-11 check digit is the standard and always
runs; the 3-digit city-code list is community-maintained data that lags behind the codes سازمان ثبت احوال actually
issues, so enabling it will reject genuine IDs carrying a newer prefix.
Algorithm
Falsy → undefined.
Length must be ≥ 8; shorter inputs are zero-padded to 10 (so 499370899 is accepted as 0499370899).
Reject all-same-digit sequences (0000000000, 1111111111, …) via the exported invalidNationalIdSequences set.
If checkPrefix === true, the leading 3 digits must be in validNationalIdPrefixes.
Standard check-digit computation: sum = Σ digit[i] * (10 - i) for i = 0..8, then digit[9] must equal sum % 11 (or 11 - sum%11 if sum%11 ≥ 2).
Look up the place
For city/province from a National ID’s 3-digit prefix, see the Place by National ID page.
Persian/Arabic digit input is NOT auto-normalized.verifyIranianNationalId("۰۴۹۹۳۷۰۸۹۹") returns false because parseInt of Persian digits yields NaN. Run autoConvertDigitsToEN first.
Return type is boolean | undefined — use === true, not truthy checks.
For test fixtures, generate IDs with createIranianNationalId(...). Don’t commit real personal data.
{"docsConfig":{"theme":"mint","$schema":"https://www.mintlify.com/docs.json","name":"Persian Tools","description":"A comprehensive, high-performance TypeScript toolkit for Persian (Farsi) text, numbers, validation, and locale utilities — works in Node.js, Bun, and the browser.","colors":{"primary":"#3b82f6","light":"#60a5fa","dark":"#1e40af"},"logo":{"light":"https://raw.githubusercontent.com/persian-tools/persian-tools/master/images/logo.png","dark":"https://raw.githubusercontent.com/persian-tools/persian-tools/master/images/logo.png","href":"https://persian-tools.usestrict.dev"},"favicon":"https://raw.githubusercontent.com/persian-tools/persian-tools/master/images/logo.png","api":{"playground":{"display":"interactive"}},"background":{"decoration":"gradient","color":{"light":"#fafafa","dark":"#0a0a0a"}},"navbar":{"links":[{"icon":"star","href":"https://persian-tools.usestrict.dev/showcase","label":"Showcase"},{"icon":"github","href":"https://github.com/persian-tools/persian-tools","label":"GitHub"},{"icon":"npm","href":"https://www.npmjs.com/package/@persian-tools/persian-tools","label":"NPM"},{"icon":"organization","href":"https://github.com/orgs/persian-tools","label":"Persian Tools Org"},{"icon":"handshake","href":"https://github.com/persian-tools/persian-tools/blob/master/CONTRIBUTING.md","label":"Contribute"}]},"footer":{"socials":{"github":"https://github.com/persian-tools/persian-tools","linkedin":"https://www.linkedin.com/company/persian-tools"},"links":[{"header":"Resources","items":[{"label":"GitHub","href":"https://github.com/persian-tools/persian-tools"},{"label":"NPM Package","href":"https://www.npmjs.com/package/@persian-tools/persian-tools"}]},{"header":"Community","items":[{"label":"Issues","href":"https://github.com/persian-tools/persian-tools/issues"},{"label":"Contributing","href":"https://github.com/persian-tools/persian-tools/blob/master/CONTRIBUTING.md"}]}]},"search":{"prompt":"Search for any Persian Tools topic..."},"seo":{"metatags":{"title":"Persian Tools","description":"A comprehensive, high-performance TypeScript toolkit for Persian (Farsi) text, numbers, validation, and locale utilities — works in Node.js, Bun, and the browser.","image":"https://raw.githubusercontent.com/persian-tools/persian-tools/master/images/logo.png","twitter:card":"summary_large_image","twitter:site":"@persian_tools","twitter:creator":"@persian_tools","twitter:title":"Persian Tools","twitter:description":"A comprehensive, high-performance TypeScript toolkit for Persian (Farsi) text, numbers, validation, and locale utilities — works in Node.js, Bun, and the browser.","twitter:image":"https://raw.githubusercontent.com/persian-tools/persian-tools/master/images/logo.png","og:title":"Persian Tools","og:description":"A comprehensive, high-performance TypeScript toolkit for Persian (Farsi) text, numbers, validation, and locale utilities — works in Node.js, Bun, and the browser.","og:image":"https://raw.githubusercontent.com/persian-tools/persian-tools/master/images/logo.png","og:url":"https://persian-tools.usestrict.dev/persian-tools","og:type":"website","og:site_name":"Persian Tools","og:locale":"en_US","og:locale:alternate":"fa_IR","article:author":"https://persian-tools.usestrict.dev","article:published_time":"2017-09-01T00:00:00+00:00","article:modified_time":"2025-10-01T00:00:00+00:00","article:section":"Tools","article:tag":"Persian, Language, Tools, Javascript, Typescript, persian tools, number to persian words, persian words to number, Arabic numbers to Persian, Arabic numbers to English, English numbers to Persian, Persian numbers to English, verify iranian national id, verify iranian card-number, half-space, digits convertor"},"indexing":"all"},"icons":{"library":"lucide"},"errors":{"404":{"redirect":true,"title":"Page Not Found","description":"The page you are looking for does not exist."}},"interaction":{"drilldown":true},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"persiantools","hasAudioNarration":false,"actualSubdomain":"persiantools","customDomains":["persian-tools.usestrict.dev"],"gitSource":{"type":"github","owner":"persian-tools","repo":"persian-tools","deployBranch":"master","contentDirectory":"website","isPrivate":true,"mountPath":"","label":""},"feedback":{"thumbs":true},"entitlements":{},"buildId":"6ac2420428f0ed956956b4bc","clientVersion":"0.0.4131","searchFilterCounts":[{"language":"default","tag":"Text Processing","count":7},{"language":"default","tag":"Number Utilities","count":6},{"language":"default","tag":"Validation","count":6},{"language":"default","tag":"Banking","count":4},{"language":"default","tag":"Getting Started","count":3},{"language":"default","tag":"Geographic","count":2},{"language":"default","tag":"Time Utilities","count":2},{"language":"default","tag":"AI Agent Skills","count":1},{"language":"default","tag":"Introduction","count":1},{"language":"default","tag":"Showcase","count":1}]},"assistantConfig":{"enableStarterQuestions":false},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"utilities/validation/national-id","slug":"/utilities/validation/national-id","pageMetadata":{"title":"National ID","description":"Validate Iranian National IDs (کد ملی) with optional city-prefix check, and generate valid synthetic IDs for fixtures.","icon":"id-card","href":"/utilities/validation/national-id"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Validate Iranian National IDs (کد ملی) with optional city-prefix check, and generate valid synthetic IDs for fixtures.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`The Iranian National ID (کد ملی) is a 10-digit code with a check digit and an embedded 3-digit city/registration prefix. Persian Tools provides validation, prefix lookup, and a generator family for tests.`}),`\n`,_jsx(Heading,{level:`2`,id:`validate`,children:`Validate`}),`\n`,_jsx(Heading,{level:`3`,id:`verifyiraniannationalid-nationalid-options`,children:_jsx(_components.code,{children:`verifyIranianNationalId(nationalId, options?)`})}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`8`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`8`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`verifyIranianNationalId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"@persian-tools/persian-tools\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`verifyIranianNationalId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"0499370899\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`); `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// true`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`verifyIranianNationalId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"1234567890\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`); `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// false (checksum fails)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`verifyIranianNationalId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`undefined`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`); `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// undefined (falsy input)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Opt in to the extra city-prefix check`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`verifyIranianNationalId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"0499370899\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`checkPrefix:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` true`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` });`})]}),`\n`]})})}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`interface`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` VerifyIranianNationalIdOptions`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`\tcheckPrefix`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` boolean`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// required once you pass an options object`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Omit the second argument entirely to get the default, which leaves the prefix check off. There is no partial\noptions object: `,_jsx(_components.code,{children:`verifyIranianNationalId(id, {})`}),` is a type error.`]}),`\n`,_jsx(Warning,{children:_jsx(_components.p,{children:`The prefix check is off by default as of v5 — it used to be on. The mod-11 check digit is the standard and always\nruns; the 3-digit city-code list is community-maintained data that lags behind the codes سازمان ثبت احوال actually\nissues, so enabling it will reject genuine IDs carrying a newer prefix.`})}),`\n`,_jsx(Heading,{level:`4`,id:`algorithm`,children:`Algorithm`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`Falsy → `,_jsx(_components.code,{children:`undefined`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`Length must be ≥ 8; shorter inputs are zero-padded to 10 (so `,_jsx(_components.code,{children:`499370899`}),` is accepted as `,_jsx(_components.code,{children:`0499370899`}),`).`]}),`\n`,_jsxs(_components.li,{children:[`Reject all-same-digit sequences (`,_jsx(_components.code,{children:`0000000000`}),`, `,_jsx(_components.code,{children:`1111111111`}),`, …) via the exported `,_jsx(_components.code,{children:`invalidNationalIdSequences`}),` set.`]}),`\n`,_jsxs(_components.li,{children:[`If `,_jsx(_components.code,{children:`checkPrefix === true`}),`, the leading 3 digits must be in `,_jsx(_components.code,{children:`validNationalIdPrefixes`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`Standard check-digit computation: `,_jsx(_components.code,{children:`sum = Σ digit[i] * (10 - i)`}),` for i = 0..8, then `,_jsx(_components.code,{children:`digit[9]`}),` must equal `,_jsx(_components.code,{children:`sum % 11`}),` (or `,_jsx(_components.code,{children:`11 - sum%11`}),` if `,_jsx(_components.code,{children:`sum%11 ≥ 2`}),`).`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`look-up-the-place`,children:`Look up the place`}),`\n`,_jsxs(_components.p,{children:[`For city/province from a National ID’s 3-digit prefix, see the `,_jsx(_components.a,{href:`/utilities/validation/place-by-national-id`,children:`Place by National ID`}),` page.`]}),`\n`,_jsx(Heading,{level:`2`,id:`generate-for-tests`,children:`Generate (for tests)`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`23`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`23`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`\tcreateIranianNationalId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`\tcreateIranianNationalIdDetailed`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`\tcreateIranianRoundNationalId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`\tvalidateNationalIdChecksum`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`\tisValidNationalIdFormat`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`} `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"@persian-tools/persian-tools\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`createIranianNationalId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(); `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// random valid ID`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`createIranianNationalId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`preventRepeatedDigits:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` true`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }); `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// forbids all-same-digit results`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`createIranianNationalId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`randomGenerator`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` () `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 0.5`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }); `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// deterministic seed for tests`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` detailed`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` createIranianNationalIdDetailed`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`preventRepeatedDigits:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` true`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`maxRetries:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 50`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` });`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// {`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// nationalId: \"1234567890\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// checkDigit: 0,`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// attempts: 1,`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// hasRepeatedDigits: false,`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// digits: [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// }`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`validateNationalIdChecksum`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`detailed`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`nationalId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`); `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// true`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`isValidNationalIdFormat`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"0499370899\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`); `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// true (just shape)`})]}),`\n`]})})}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`12`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`12`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`interface`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` NationalIdGenerationOptions`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`\tpreventRepeatedDigits`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`?:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` boolean`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`\tmaxRetries`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`?:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` number`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`\trandomGenerator`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`?:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` () `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` number`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`interface`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` NationalIdGenerationResult`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`\tnationalId`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` string`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`\tcheckDigit`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` number`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`\tattempts`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` number`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`\thasRepeatedDigits`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` boolean`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`\tdigits`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` number`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[];`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`pitfalls`,children:`Pitfalls`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Persian/Arabic digit input is NOT auto-normalized.`}),` `,_jsx(_components.code,{children:`verifyIranianNationalId(\"۰۴۹۹۳۷۰۸۹۹\")`}),` returns `,_jsx(_components.code,{children:`false`}),` because `,_jsx(_components.code,{children:`parseInt`}),` of Persian digits yields `,_jsx(_components.code,{children:`NaN`}),`. Run `,_jsx(_components.code,{children:`autoConvertDigitsToEN`}),` first.`]}),`\n`,_jsxs(_components.li,{children:[_jsxs(_components.strong,{children:[`Return type is `,_jsx(_components.code,{children:`boolean | undefined`})]}),` — use `,_jsx(_components.code,{children:`=== true`}),`, not truthy checks.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`For test fixtures`}),`, generate IDs with `,_jsx(_components.code,{children:`createIranianNationalId(...)`}),`. Don’t commit real personal data.`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`source`,children:`Source`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`src/modules/nationalId/index.ts`}),`, `,_jsx(_components.code,{children:`src/modules/nationalId/create-national-id.ts`}),` · Tests: `,_jsx(_components.code,{children:`test/verifyIranianNationalId.spec.ts`})]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"National ID","description":"Validate Iranian National IDs (کد ملی) with optional city-prefix check, and generate valid synthetic IDs for fixtures.","icon":"id-card","href":"/utilities/validation/national-id"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Validate","slug":"validate","depth":2,"children":[{"title":"verifyIranianNationalId(nationalId, options?)","slug":"verifyiraniannationalid-nationalid-options","depth":3,"children":[]},{"title":"Algorithm","slug":"algorithm","depth":4,"children":[]}]},{"title":"Look up the place","slug":"look-up-the-place","depth":2,"children":[]},{"title":"Generate (for tests)","slug":"generate-for-tests","depth":2,"children":[]},{"title":"Pitfalls","slug":"pitfalls","depth":2,"children":[]},{"title":"Source","slug":"source","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"persiantools","siteName":"Persian Tools","title":"Persian Tools","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-09-28T11:39:59.098Z","originalFileLocation":"utilities/validation/national-id.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Validate Iranian National IDs (کد ملی) with optional city-prefix check, and generate valid synthetic IDs for fixtures.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Persian Tools\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"https://raw.githubusercontent.com/persian-tools/persian-tools/master/images/logo.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"https://raw.githubusercontent.com/persian-tools/persian-tools/master/images/logo.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"https://raw.githubusercontent.com/persian-tools/persian-tools/master/images/logo.png\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/png\" href=\"https://raw.githubusercontent.com/persian-tools/persian-tools/master/images/logo.png\">\u003cmeta data-mint-head property=\"og:title\" content=\"Persian Tools\">\u003cmeta data-mint-head property=\"og:description\" content=\"A comprehensive, high-performance TypeScript toolkit for Persian (Farsi) text, numbers, validation, and locale utilities — works in Node.js, Bun, and the browser.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Persian Tools\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://persian-tools.usestrict.dev/utilities/validation/national-id\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://raw.githubusercontent.com/persian-tools/persian-tools/master/images/logo.png\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Persian Tools\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"A comprehensive, high-performance TypeScript toolkit for Persian (Farsi) text, numbers, validation, and locale utilities — works in Node.js, Bun, and the browser.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://raw.githubusercontent.com/persian-tools/persian-tools/master/images/logo.png\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"https://mintlify.s3.us-west-1.amazonaws.com/persiantools/_generated/favicon/browserconfig.xml?v=3\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Persian Tools\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#3b82f6\">\u003cmeta data-mint-head name=\"og:locale\" content=\"en_US\">\u003cmeta data-mint-head name=\"image\" content=\"https://raw.githubusercontent.com/persian-tools/persian-tools/master/images/logo.png\">\u003cmeta data-mint-head name=\"twitter:creator\" content=\"@persian_tools\">\u003cmeta data-mint-head name=\"og:locale:alternate\" content=\"fa_IR\">\u003cmeta data-mint-head name=\"article:author\" content=\"https://persian-tools.usestrict.dev\">\u003cmeta data-mint-head name=\"article:published_time\" content=\"2017-09-01T00:00:00+00:00\">\u003cmeta data-mint-head name=\"article:modified_time\" content=\"2025-10-01T00:00:00+00:00\">\u003cmeta data-mint-head name=\"article:section\" content=\"Tools\">\u003cmeta data-mint-head name=\"article:tag\" content=\"Persian, Language, Tools, Javascript, Typescript, persian tools, number to persian words, persian words to number, Arabic numbers to Persian, Arabic numbers to English, English numbers to Persian, Persian numbers to English, verify iranian national id, verify iranian card-number, half-space, digits convertor\">\u003clink data-mint-head rel=\"canonical\" href=\"https://persian-tools.usestrict.dev/utilities/validation/national-id\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/utilities/validation/national-id.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://persian-tools.usestrict.dev/#organization\",\"name\":\"Persian Tools\",\"url\":\"https://persian-tools.usestrict.dev\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://raw.githubusercontent.com/persian-tools/persian-tools/master/images/logo.png\"}},{\"@type\":\"WebSite\",\"@id\":\"https://persian-tools.usestrict.dev#website\",\"name\":\"Persian Tools\",\"url\":\"https://persian-tools.usestrict.dev\",\"publisher\":{\"@id\":\"https://persian-tools.usestrict.dev/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://persian-tools.usestrict.dev/utilities/validation/national-id#webpage\",\"url\":\"https://persian-tools.usestrict.dev/utilities/validation/national-id\",\"name\":\"National ID\",\"description\":\"Validate Iranian National IDs (کد ملی) with optional city-prefix check, and generate valid synthetic IDs for fixtures.\",\"dateModified\":\"2026-09-28T11:39:59.098Z\",\"isPartOf\":{\"@id\":\"https://persian-tools.usestrict.dev#website\"},\"breadcrumb\":{\"@id\":\"https://persian-tools.usestrict.dev/utilities/validation/national-id#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://persian-tools.usestrict.dev/utilities/validation/national-id#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Persian Tools\",\"item\":\"https://persian-tools.usestrict.dev\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"National ID\",\"item\":\"https://persian-tools.usestrict.dev/utilities/validation/national-id\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://persian-tools.usestrict.dev/utilities/validation/national-id#article\",\"headline\":\"National ID\",\"name\":\"National ID\",\"description\":\"Validate Iranian National IDs (کد ملی) with optional city-prefix check, and generate valid synthetic IDs for fixtures.\",\"url\":\"https://persian-tools.usestrict.dev/utilities/validation/national-id\",\"mainEntityOfPage\":{\"@id\":\"https://persian-tools.usestrict.dev/utilities/validation/national-id#webpage\"},\"image\":\"https://raw.githubusercontent.com/persian-tools/persian-tools/master/images/logo.png\",\"dateModified\":\"2026-09-28T11:39:59.098Z\",\"publisher\":{\"@id\":\"https://persian-tools.usestrict.dev/#organization\"},\"isPartOf\":{\"@id\":\"https://persian-tools.usestrict.dev#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Persian Tools\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Persian Tools\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/utilities/validation/national-id.md","siteName":"Persian Tools","nav":{"global":null,"groups":[{"group":"Introduction","icon":"book-open","pages":[{"title":"Persian Tools","icon":"home","href":"/introduction"}]},{"group":"Showcase","icon":"star","pages":[{"title":"Who's Using Persian Tools?","icon":"building","href":"/showcase"}]},{"group":"AI Agent Skills","icon":"robot","pages":[{"title":"AI Agent Skills","icon":"robot","href":"/agent-skills"}]},{"group":"Getting Started","icon":"rocket","pages":[{"title":"Installation","icon":"download","href":"/getting-started/installation"},{"title":"Usage Guide","icon":"play","href":"/getting-started/usage"},{"title":"Examples","icon":"lightbulb","href":"/getting-started/examples"}]},{"group":"Number Utilities","icon":"calculator","pages":[{"title":"Number to Words","icon":"calculator","href":"/utilities/numbers/number-to-words"},{"title":"Words to Number","icon":"spell-check","href":"/utilities/numbers/words-to-number"},{"title":"Money Words to Number","icon":"coins","href":"/utilities/numbers/money-words-to-number"},{"title":"Digit Conversion","icon":"calculator","href":"/utilities/numbers/digits"},{"title":"Commas","icon":"comma","href":"/utilities/numbers/commas"},{"title":"Ordinal Suffix","description":"Add Persian ordinal suffix to a Persian word, or strip it back to the cardinal form.","icon":"list-ordered","href":"/utilities/numbers/ordinal-suffix"}]},{"group":"Validation","icon":"shield-check","pages":[{"title":"National ID","icon":"id-card","href":"/utilities/validation/national-id"},{"title":"Place by National ID","description":"Look up the registering city and province for an Iranian National ID by its 3-digit prefix.","icon":"map-pin","href":"/utilities/validation/place-by-national-id"},{"title":"Postal Code Location","icon":"mailbox","href":"/utilities/validation/postal-code"},{"title":"Legal ID","icon":"building","href":"/utilities/validation/legal-id"},{"title":"Card Number","icon":"credit-card","href":"/utilities/validation/card-number"},{"title":"Phone Number","icon":"phone","href":"/utilities/validation/phone-number"}]},{"group":"Text Processing","icon":"text","pages":[{"title":"Persian Detection","icon":"check","href":"/utilities/text/is-persian"},{"title":"Arabic Detection","icon":"check","href":"/utilities/text/is-arabic"},{"title":"Persian Character Normalization","icon":"wand-sparkles","href":"/utilities/text/persian-chars"},{"title":"Half-Space","icon":"minus","href":"/utilities/text/half-space"},{"title":"Slugify","icon":"link","href":"/utilities/text/slugify"},{"title":"URL Fix","icon":"link","href":"/utilities/text/url-fix"},{"title":"Text Analyzer","icon":"chart-bar","href":"/utilities/text/text-analyzer"}]},{"group":"Banking","icon":"building-columns","pages":[{"title":"Sheba (IBAN)","icon":"landmark","href":"/utilities/banking/sheba"},{"title":"Bill","icon":"receipt","href":"/utilities/banking/bill"},{"title":"Bank Name from Card Number","icon":"building-columns","href":"/utilities/banking/bank-name"},{"title":"Extract Card Numbers","icon":"credit-card","href":"/utilities/banking/extract-card-numbers"}]},{"group":"Geographic","icon":"map-location-dot","pages":[{"title":"Capital by Province","icon":"landmark","href":"/utilities/geographic/capital-by-province"},{"title":"Province from Coordinates","icon":"map","href":"/utilities/geographic/province-from-coordinate"}]},{"group":"Time Utilities","icon":"clock","pages":[{"title":"Time Ago","icon":"clock","href":"/utilities/time/time-ago"},{"title":"Remaining Time","icon":"hourglass","href":"/utilities/time/remaining-time"}]},{"group":"Vehicle","icon":"car","pages":[{"title":"Vehicle Plate","icon":"car","href":"/utilities/vehicle/numberplate"}]}]},"basePath":"","title":"Persian Tools","buildId":"dpl_5joLUXmnJgwqjrHAS4dxZrQTdxgh","deploymentId":"dpl_5joLUXmnJgwqjrHAS4dxZrQTdxgh","dynamics":[],"chunks":[]}