REGEXVAULTv2.0
Identity & PII/National Identity Numbers
Verified Safe

Chinese Citizen ID Number (Shenfenzheng) Regex for JavaScript

/^[1-8][0-9]{5}((?:19|20)[0-9]{2})(0[1-9]|1[0-2])(0[1-9]|[12][0-9]|3[01])[0-9]{3}[0-9X]$/i

What this pattern does

This page provides a comprehensive, battle-tested regular expression for matching chinese citizen id number (shenfenzheng), ported and verified for JavaScript. Identity and credential patterns need both correctness and safety, since they're frequent targets for adversarial input. The snippet below is ready to drop into your JavaScript project — whether you're validating in an Express middleware, a Next.js API route, or a client-side form.

Javascript Implementation

Javascript
// Chinese Citizen ID Number (Shenfenzheng)
// ReDoS-safe | RegexVault — Identity & PII > National Identity Numbers

const chineseCitizenIdNumberShenfenzhengRegex = /^[1-8][0-9]{5}((?:19|20)[0-9]{2})(0[1-9]|1[0-2])(0[1-9]|[12][0-9]|3[01])[0-9]{3}[0-9X]$/i;

function validateChineseCitizenIdNumberShenfenzheng(input: string): boolean {
  return chineseCitizenIdNumberShenfenzhengRegex.test(input);
}

// Example
console.log(validateChineseCitizenIdNumberShenfenzheng("110101199003077515")); // true

Test Cases

Matches (Valid)
Rejects (Invalid)
11010119900307751501010119900307771X
440301200001010002110101199013077515
31010519900307771X1101011990030777151

When to use this pattern

This pattern is drawn from the Identity & PII > National Identity Numbers category and carries a ReDoS-safe certification. That matters for JavaScript developers because especially critical in long-running Node.js event loops where a ReDoS vulnerability can block the entire process. RegexVault audits patterns against known backtracking attack vectors, ensuring you have the necessary context before using this regex in a high-stakes production environment.

Common Pitfalls

The sequence number (positions 15-17) encodes gender: odd=male, even=female. Region codes starting with 9 are used for special purposes (overseas Chinese, some SAR contexts). X as check character is uppercase only in official use.

Technical Notes

Structure: 6-digit region code (first digit 1-8) + 8-digit birthdate (YYYYMMDD) + 3-digit sequence + 1 check character. Check character X represents 10. Region code first digit 1-8 corresponds to Chinese provinces (9 not currently used for mainland). Checksum uses ISO 7064 MOD 11-2.

Have a pattern that belongs in the vault?

Submit it for review — community-verified patterns get credited to your GitHub handle. Free submissions join the queue. Priority review available for $15.

Submit a Pattern