npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@neuception/gst-toolkit

v0.2.0

Published

Zero-dependency toolkit for Indian GST: GSTIN validation & checksum, GST calculation (CGST/SGST/IGST), and amount-in-words in the Indian numbering system.

Readme

gst-toolkit

npm version license

Zero-dependency TypeScript toolkit for Indian GST:

  • GSTIN validation — structure, state code, official checksum, holder type, masking
  • 🆔 PAN validation — structure + holder-type detection
  • 🧮 GST calculation — inclusive/exclusive amounts with CGST/SGST/IGST split + round-off
  • 🔤 Amount in words — Indian numbering system (lakh/crore), ready for invoices
  • 💸 INR formatting — correct Indian digit grouping (₹1,25,000.00)
  • 📅 Financial year — Indian FY / assessment-year helpers

Fully typed, tree-shakeable, ESM + CJS, no runtime dependencies.

Built and maintained alongside GSTInvoicePDF.com — a free GST invoice generator for Indian businesses. Try the live GST calculator and HSN/SAC finder.

Install

npm install @neuception/gst-toolkit

Usage

import {
  validateGSTIN,
  isValidGSTIN,
  getStateFromGSTIN,
  calculateGST,
  amountInWords,
  formatINR,
} from '@neuception/gst-toolkit';

GSTIN validation

isValidGSTIN('27AAPFU0939F1ZV'); // => true

validateGSTIN('27AAPFU0939F1ZV');
// => {
//   valid: true,
//   stateCode: '27',
//   state: 'Maharashtra',
//   pan: 'AAPFU0939F'
// }

validateGSTIN('27AAPFU0939F1ZX');
// => { valid: false, reason: 'Checksum digit does not match', ... }

getStateFromGSTIN('29AAGCB7383J1Z5'); // => 'Karnataka'

maskGSTIN('27AAPFU0939F1ZV'); // => '27XXXXXXXX9F1ZV'  (safe for display)

PAN validation

isValidPAN('AAPFU0939F'); // => true

validatePAN('ABCPD1234E');
// => { valid: true, holderType: 'Individual' }   // 4th char encodes the type

getPANHolderType('ABCCD1234E'); // => 'Company'

Validation checks the 15-character structure, a recognised state code, and the GSTN check digit — so typos and fabricated numbers are caught, not just format errors.

GST calculation

// Add 18% GST to a base amount (intra-state)
calculateGST({ amount: 1000, rate: 18 });
// => { base: 1000, gst: 180, total: 1180, cgst: 90, sgst: 90, igst: 0, interState: false, rate: 18 }

// Inter-state supply → IGST
calculateGST({ amount: 1000, rate: 18, interState: true });
// => { ..., cgst: 0, sgst: 0, igst: 180 }

// Reverse-calculate from a GST-inclusive price
calculateGST({ amount: 1180, rate: 18, type: 'inclusive' });
// => { base: 1000, gst: 180, total: 1180, ... }

// Just split a known GST amount
splitGST(180);       // => { cgst: 90, sgst: 90, igst: 0 }
splitGST(180, true); // => { cgst: 0, sgst: 0, igst: 180 }

// Round an invoice total to the nearest rupee (for the "Round Off" line)
roundOff(1180.6); // => { rounded: 1181, roundOff: 0.4 }

Amount in words & INR formatting

amountInWords(125000.5);
// => 'One Lakh Twenty Five Thousand Rupees and Fifty Paise Only'

numberToIndianWords(10000000); // => 'One Crore'

formatINR(1234567.5);                 // => '₹12,34,567.50'
formatINR(1000, { symbol: false });   // => '1,000.00'

Financial year

getFinancialYear(new Date(2026, 5, 15)); // => '2026-27'  (Indian FY: Apr–Mar)
getAssessmentYear(new Date(2026, 5, 15)); // => '2027-28'
getFinancialYearRange(new Date(2026, 5, 15));
// => { start: <1 Apr 2026>, end: <31 Mar 2027>, label: '2026-27' }

API

| Function | Description | | --- | --- | | validateGSTIN(gstin) | Full validation → { valid, reason?, stateCode?, state?, pan?, holderType? } | | isValidGSTIN(gstin) | Boolean convenience check | | getStateFromGSTIN(gstin) | State/UT name from the state code | | getPANFromGSTIN(gstin) | Extract the embedded PAN | | maskGSTIN(gstin) | Mask the middle for safe display | | computeGstinCheckDigit(first14) | Compute the GSTN check digit | | validatePAN(pan) | Full PAN validation → { valid, reason?, holderType? } | | isValidPAN(pan) | Boolean convenience check | | getPANHolderType(pan) | Holder type from the 4th character | | calculateGST({ amount, rate, type?, interState? }) | Full GST breakdown | | splitGST(gstAmount, interState?) | Split GST into CGST/SGST/IGST | | roundOff(amount) | Nearest-rupee rounding + adjustment | | numberToIndianWords(n) | Integer → Indian-system words | | amountInWords(amount, options?) | Money → words with Rupees/Paise | | formatINR(amount, options?) | Indian-grouped currency string | | getFinancialYear(date?) | Indian FY as "YYYY-YY" | | getFinancialYearRange(date?) | FY start/end dates + label | | getAssessmentYear(date?) | Assessment year as "YYYY-YY" |

Also exported: GST_STATE_CODES, GSTIN_REGEX, PAN_REGEX, PAN_HOLDER_TYPES, and all TypeScript types.

Notes

GST rates and rules change over time; this library provides calculation and validation primitives, not tax advice. Always confirm rates and applicability against the official GST portal.

License

MIT © Mohit Sawhney