Every Pakistani website and app ends up writing the same code. Check a CNIC. Clean up a phone number that someone typed as “0300 1234567” or “+92-300-1234567”. Validate an IBAN before sending a payout. Work out the income tax on a salary. Show “Rs 1,50,000” instead of “Rs 150,000”. Write “One Lakh Fifty Thousand Rupees Only” on an invoice.
Most developers copy a half-working snippet from somewhere, or spend a day getting it right, and the next developer does the same again. pakistan-toolkit puts all of it in one free, open-source package, tested and ready to use.
What is pakistan-toolkit?
pakistan-toolkit is a JavaScript library made by ZexCart. You add it to your project with one command, and you get ready-made functions for the things every Pakistani app needs:
| Module | What it does |
|---|---|
| CNIC | Validate, format (35202-1234567-3), mask, and read the region and gender digit |
| Phone | Accepts 0300…, +92…, 0092… and more. Gives international, local and WhatsApp formats and the original network |
| IBAN | Full mod-97 checksum validation and bank detection for 26 banks, including JazzCash and Easypaisa |
| NTN | Classic 1234567-8 NTNs and CNIC-based NTNs |
| Income tax | FBR salaried slabs for FY2024-25, FY2025-26 and FY2026-27, with surcharge, take-home pay and year-to-year comparison |
| Currency | Lakh/crore formatting (Rs 12,34,56,789) and short forms (“25 lakh”, “15 crore”) |
| Amount in words | Cheque-style text: “One Lakh Fifty Thousand Rupees and Fifty Paisa Only” |
| Data | 7 provinces and territories, 50+ cities with Urdu names, 26 banks with IBAN codes. Also available as JSON |
It has zero dependencies, includes TypeScript types, and works in Node.js, browsers, React, Next.js, Deno and Bun. It is released under the MIT license, so you can use it for free in personal and commercial projects.
Try it online
These free tools run on pakistan-toolkit. No sign-up and nothing to install. Everything runs in your browser, so the numbers you type are not sent anywhere.
Salary tax calculator
Monthly income tax and take-home pay under the new FY2026-27 slabs, and how much you save compared to last year.
Amount in words
Write any amount the Pakistani way, in lakh and crore, ready for a cheque or invoice.
CNIC checker
Check if a CNIC number is in the right format, and see its region and gender digit.
Phone & IBAN checker
Check a Pakistani mobile number or a bank IBAN (with full checksum) and see the network or bank.
The tax calculator is an estimate for salaried individuals and is not tax advice. It does not include exemptions, tax credits or other income. CNIC, phone and IBAN checks verify the format and checksum only; they do not contact NADRA, PTA or any bank.
Who is it for?
- E-commerce stores: validate phone numbers at checkout and save them in one clean format for SMS and WhatsApp.
- Sign-up and KYC forms: check CNIC format and show it masked on screen.
- HR and payroll software: calculate monthly tax deduction and take-home salary under the latest FBR slabs.
- Invoicing and accounting apps: lakh/crore formatting and amounts in words.
- Payout and wallet apps: validate an IBAN before sending a Raast or IBFT transfer.
- Address forms: province and city dropdowns, with Urdu labels.
How to install
If your project uses npm:
npm install pakistan-toolkit
Or use it straight in a web page from a CDN, with nothing to install:
<script type="module">
import { formatPKR } from 'https://cdn.jsdelivr.net/npm/pakistan-toolkit/+esm';
console.log(formatPKR(150000)); // Rs 1,50,000
</script>
Examples
CNIC validation
import { isValidCNIC, parseCNIC, maskCNIC } from 'pakistan-toolkit';
isValidCNIC('3520212345673'); // true (dashes are optional)
maskCNIC('35202-1234567-3'); // '35202-*******-3'
parseCNIC('42101-1234567-8');
// { valid: true, formatted: '42101-1234567-8', region: 'Sindh', gender: 'female', ... }
The first digit of a CNIC shows the region (1 KP, 3 Punjab, 4 Sindh, 5 Balochistan, 6 Islamabad, 7 Gilgit-Baltistan, 8 AJK) and the last digit is odd for men and even for women. The library checks the format only. It does not contact NADRA.
Mobile numbers
import { formatPhone, getOperator } from 'pakistan-toolkit';
formatPhone('0300 1234567'); // '+923001234567'
formatPhone('+92-300-1234567', 'local'); // '0300-1234567'
formatPhone('03001234567', 'whatsapp'); // '923001234567' (for wa.me links)
getOperator('03451234567'); // 'Telenor'
Because people can move their number to another network, getOperator returns the network the number’s prefix was first given to, not necessarily the network it is on today.
IBAN validation
import { isValidIBAN, parseIBAN } from 'pakistan-toolkit';
isValidIBAN('PK36 SCBL 0000 0011 2345 6702'); // true
parseIBAN('PK36SCBL0000001123456702').bank.name;
// 'Standard Chartered Bank (Pakistan) Limited'
A Pakistani IBAN has 24 characters: PK, two check digits, a four-letter bank code and a 16-digit account number. The library runs the same mod-97 checksum that banks use, so a single mistyped digit is caught before you send money.
Salary income tax (FY2026-27)
import { calculateSalaryTax, compareSalaryTax } from 'pakistan-toolkit';
calculateSalaryTax({ monthlyIncome: 200000 });
// { monthlyTax: 13000, monthlyTakeHome: 187000, effectiveRate: 6.5, ... }
compareSalaryTax({ monthlyIncome: 300000, from: '2025-26', to: '2026-27' });
// { monthlySaving: 4166.67, annualSaving: 50000, ... }
These are the salaried slabs for FY2026-27 (Finance Act 2026) used by the library:
| Annual taxable income (Rs) | Tax |
|---|---|
| Up to 600,000 | 0 |
| 600,001 – 1,200,000 | 1% of the amount over 600,000 |
| 1,200,001 – 2,200,000 | 6,000 + 11% over 1,200,000 |
| 2,200,001 – 3,200,000 | 116,000 + 20% over 2,200,000 |
| 3,200,001 – 4,100,000 | 316,000 + 25% over 3,200,000 |
| 4,100,001 – 5,600,000 | 541,000 + 29% over 4,100,000 |
| 5,600,001 – 7,000,000 | 976,000 + 32% over 5,600,000 |
| Above 7,000,000 | 1,424,000 + 35% over 7,000,000 |
The 9% surcharge on salaried income above Rs 10 million, which applied in FY2025-26, has been removed for FY2026-27. The library also includes the FY2024-25 and FY2025-26 slabs, so you can compare years.
Lakh/crore formatting and amount in words
import { formatPKR, toShortPKR, amountToWords } from 'pakistan-toolkit';
formatPKR(1500000); // 'Rs 15,00,000'
toShortPKR(25000000); // '2.5 crore'
amountToWords(150250.5);
// 'One Lakh Fifty Thousand Two Hundred Fifty Rupees and Fifty Paisa Only'
Provinces, cities and banks
import { getCitiesByProvince, findBank } from 'pakistan-toolkit';
getCitiesByProvince('Sindh');
// [{ name: 'Karachi', urdu: 'کراچی', province: 'PK-SD' }, ...]
findBank('hbl');
// { code: 'HABB', name: 'Habib Bank Limited', short: 'HBL', type: 'conventional' }
Not using JavaScript? The same data is available as plain JSON files in the data folder on GitHub, so you can use it from PHP, Python, Laravel, Django or import it into a database.
What’s coming next
- JazzCash and Easypaisa payment integration helpers
- Amount in words in Urdu (ایک لاکھ پچاس ہزار)
- Tax slabs for non-salaried individuals and AOPs
- Federal and provincial sales tax helpers
- A Python version
Have an idea or found a mistake? Open an issue on GitHub or contact us. Contributions are welcome, especially missing banks, cities and new tax years.
Frequently asked questions
Is pakistan-toolkit free?
Yes. It is open source under the MIT license. You can use it in personal and commercial projects for free.
Does it check a CNIC with NADRA?
No. It checks that the number has the correct format. Checking whether a CNIC is real requires NADRA’s own verification service.
Is the tax calculator up to date?
It includes the salaried slabs for FY2026-27 from the Finance Act 2026, as well as the two previous years. New tax years are added when a new Finance Act is passed.
Can I use it without coding?
Yes. The tools at the top of this page are free online versions of the tax calculator, amount in words, and the CNIC, phone and IBAN checkers.
Try it now
Use the free online tools above, or add pakistan-toolkit to your next project. See all Dev Tools. If it saves you time, a star on GitHub helps others find it.
Pingback: pakistan-mcp: Free MCP Server for Claude, Cursor & VS Code (FBR Tax, IBAN, Urdu) | ZexCart