GSTIN
Validator and formatter for GSTIN (Goods and Services Tax Identification Number).
GSTIN is the unique 15-character identifier assigned to every GST-registered business in India by the GSTN (Goods and Services Tax Network). It is required for:
Issuing GST-compliant tax invoices (B2B and B2C)
Filing GSTR-1, GSTR-3B, and other GST returns (CBIC mandate)
Input Tax Credit (ITC) reconciliation
E-waybill generation (goods movement over ₹50,000)
E-invoicing (mandatory for businesses with turnover >₹5 crore from 2023)
Vendor onboarding / KYC by procuring entities
GSTIN structure (15 characters):
Positions 0-1: 2-digit GST state code (01–38, including legacy 25 and 28)
Positions 2-11: Taxpayer's PAN (10 characters, A-Z{5}0-9{4}A-Z with category rules)
Position 12: Entity number (1 alphanumeric, typically '1'–'9' or 'A'–'Z')
Position 13: Literal 'Z' (fixed per GSTN specification)
Position 14: GSTN base-36 checksum character (computed via io.github.kotindia.internal.GstinChecksum)
Checksum: GSTN base-36 weighted-sum algorithm. Reference: https://github.com/tk120404/gst and https://github.com/mastermunj/format-utils
Valid state codes (01–38): All 38 assigned GST state codes are accepted, including:
Legacy code 25 (Daman & Diu — merged into 26 in 2020; existing GSTINs remain valid)
Legacy code 28 (old Andhra Pradesh — replaced by 37 post-2014; existing GSTINs remain valid)
Code 38 (Ladakh — created post-2019 reorganisation)
GSTIN is a public business identifier — searchable on the GSTN taxpayer portal (https://services.gstn.gov.in/). It is NOT personal PII. No mask() method is provided.
Accepted input forms (all normalised before validation):
Canonical uppercase:
"27AAPFU0939F1ZV"Lowercase:
"27aapfu0939f1zv"— normalised to uppercaseWith internal space:
"27 AAPFU0939F1ZV"— whitespace strippedWhitespace-padded:
" 27AAPFU0939F1ZV "— trimmed + stripped
This object is stateless and thread-safe.
Samples
GSTIN.validate("27AAPFU0939F1ZV") // ValidationResult.Valid
GSTIN.format("27aapfu0939f1zv") // "27AAPFU0939F1ZV"