Skip to content

Rupee formatting

import { formatPKR, formatLakh } from 'pakdatakit/format'

Two ways to show a rupee amount: with comma separators and the Rs. prefix, or in the lakh and crore units used for prices and salaries in Pakistan.

Rs. 12,500,000, 1.25 Crore

formatPKR()
Rs. 12,500,000
formatLakh()
1.25 Crore
import { formatPKR, formatLakh } from 'pakdatakit';
formatPKR(150000.4);
// → 'Rs. 150,000'
formatLakh(2500000);
// → '25 Lakh'
formatLakh(125000000);
// → '12.5 Crore'
function formatPKR(amount: number): string;

Parameters. amount: in PKR.

Returns the amount with comma separators, rounded to whole rupees, such as "Rs. 150,000". Negative amounts are prefixed with -: "-Rs. 500".

Caveats. Throws a RangeError if amount is NaN or infinite.

Related: formatLakh().

function formatLakh(amount: number): string;

Parameters. amount: in PKR.

Returns amounts of 1 crore or more as "N Crore" (10000000 → "1 Crore"), amounts of 1 lakh or more as "N Lakh" (2500000 → "25 Lakh"), and smaller amounts as formatPKR() does. Negative amounts are prefixed with -.

Caveats. Values are rounded to two decimals before the unit is chosen, so 9999999 is "1 Crore", not "100 Lakh". Throws a RangeError if amount is NaN or infinite.

Related: formatPKR(), numbers in words for cheques.