Skip to content

getCheckCode(id) ​

Calculate the check digit (last digit) of an ID number.

Signature ​

typescript
function getCheckCode(id: string): string | null

Parameters ​

ParameterTypeDescription
idstringID number (first 17 digits)

Returns ​

Returns the computed check digit (0-9 or X). Returns null if the input format is invalid.

Live Demo ​

Example ​

typescript
import { getCheckCode } from 'china-id-card'

getCheckCode('62292219780811849')  // → '8'
getCheckCode('31000019810227632')  // → '3'

基于 GB 11643-1999 标准