Skip to content

Numbers in words

import { numberToWords, amountInWords } from 'pakdatakit/words'

Writes numbers the way they are said in Pakistan: hundred, thousand, lakh, crore, arab and kharab, not million and billion. amountInWords() adds rupees and paisa, as on cheques and invoices, in English or Urdu.

one lakh twenty-five thousand rupees and fifty paisa

In words
one lakh twenty-five thousand rupees and fifty paisa
Cheque style
Rupees One Lakh Twenty-Five Thousand and Fifty Paisa Only
import { numberToWords, amountInWords } from 'pakdatakit';
numberToWords(12500000);
// → 'one crore twenty-five lakh'
amountInWords(125000.5);
// → 'one lakh twenty-five thousand rupees and fifty paisa'
amountInWords(125000, { cheque: true });
// → 'Rupees One Lakh Twenty-Five Thousand Only'
amountInWords(125000, { language: 'ur', cheque: true });
// → 'ایک لاکھ پچیس ہزار روپے صرف'
function numberToWords(n: number, options?: NumberToWordsOptions): string;
type WordsLanguage = 'en' | 'ur';
interface NumberToWordsOptions {
language?: WordsLanguage; // default 'en'
}

Parameters. n: a safe integer; negative numbers start with minus (منفی in Urdu). options.language: 'en' (the default) or 'ur'.

Returns the number in words: numberToWords(125000) is "one lakh twenty-five thousand", and in Urdu ایک لاکھ پچیس ہزار.

Caveats. Throws a RangeError if n is not a safe integer, or if language is not 'en' or 'ur'. In Urdu, every number from 0 to 99 has a word of its own (پچیس for 25), not tens plus ones.

Related: amountInWords().

function amountInWords(amount: number, options?: AmountInWordsOptions): string;
interface AmountInWordsOptions {
language?: WordsLanguage; // default 'en'
cheque?: boolean;
}

Parameters. amount: in PKR, zero or more. options.language: 'en' or 'ur'. options.cheque: cheque style, "Rupees One Lakh Twenty-Five Thousand Only" in English, or the words followed by روپے صرف in Urdu.

Returns the amount in words, with paisa: amountInWords(125000.5) is "one lakh twenty-five thousand rupees and fifty paisa".

Caveats. Amounts are rounded to the nearest paisa. Throws a RangeError if amount is negative, not finite or too large.

Related: numberToWords(), rupee formatting for Rs. 150,000 and 25 Lakh.