Skip to content

NTN and STRN

import { analyzeNTN, validateNTN, validateSTRN } from 'pakdatakit/tax'

Checks the shape of a National Tax Number and a Sales Tax Registration Number. Individuals use their 13-digit CNIC as their NTN (since the Finance Act 2015). Companies and associations of persons have a 7-digit NTN, often written with an 8th check digit as 1234567-8.

analyzeNTN() Valid validateSTRN() Valid

NTN type
Business
NTN formatted
1234567-8
import { analyzeNTN, validateNTN, validateSTRN } from 'pakdatakit';
analyzeNTN('1234567-8');
// → {
// "type": "business",
// "digits": "12345678",
// "formatted": "1234567-8"
// }
analyzeNTN('35202-1234567-1');
// → {
// "type": "individual",
// "digits": "3520212345671",
// "formatted": "35202-1234567-1"
// }
validateNTN('12345');
// → false
validateSTRN('12-34-5678-901-23');
// → true
function analyzeNTN(ntn: string): NTNInfo | null;
type NTNType = 'individual' | 'business';
interface NTNInfo {
type: NTNType;
digits: string; // 7, 8 or 13 digits, without separators
formatted: string; // 1234567-8, or #####-#######-# for a CNIC
}

Parameters. ntn: an NTN in any common format. A CNIC is read as an individual’s NTN; 7 digits, optionally followed by a check digit, as a business NTN.

Returns the type, the digits and a display form, or null when the format is not valid.

Caveats. FBR does not publish the check-digit algorithm, so the check digit is not verified.

Related: validateNTN(), CNIC.

function validateNTN(ntn: string): boolean;

Parameters. ntn: as for analyzeNTN().

Returns true when the format is valid: a CNIC for individuals, or 7 digits (optionally followed by a check digit) for businesses.

Related: analyzeNTN().

function validateSTRN(strn: string): boolean;

Parameters. strn: 13 digits, with optional spaces or dashes.

Returns true when the format is valid.

Caveats. FBR does not publish a check-digit algorithm or the meaning of the digit groups, so this validates the format only.

Related: Sales tax, FBR Digital Invoicing.