If your app takes GST numbers from customers or vendors, you'll get typos, made-up numbers, and numbers that were valid last year and are cancelled now. Each needs a different check. Here are all three, cheapest first.
1. Format: 15 characters, in a fixed shape
A GSTIN looks like 22AAACL6442L1ZK:
| Position | Meaning | Example |
|---|---|---|
| 1–2 | State code (01–38, 97 for other territory) | 22 = Chhattisgarh |
| 3–12 | The holder's PAN | AAACL6442L |
| 13 | Entity number for that PAN in that state (1–9, then A–Z) | 1 |
| 14 | Z by default | Z |
| 15 | Check character | K |
const GSTIN_RE = /^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z][1-9A-Z]Z[0-9A-Z]$/; 2. Checksum: catches most typos without any network call
The 15th character is a mod-36 check over the first 14. Each character maps to its index in 0-9A-Z; odd positions are multiplied by 1 and even positions by 2; each product is split into quotient and remainder by 36 and both are added up.
const CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; function gstinCheckChar(first14) { let sum = 0; for (let i = 0; i < 14; i++) { const p = CHARS.indexOf(first14[i]) * (i % 2 ? 2 : 1); sum += Math.floor(p / 36) + (p % 36); } return CHARS[(36 - (sum % 36)) % 36]; } function isValidGstin(g) { g = g.trim().toUpperCase(); return GSTIN_RE.test(g) && gstinCheckChar(g.slice(0, 14)) === g[14]; } isValidGstin('22AAACL6442L1ZK'); // true isValidGstin('22AAACL6442L1ZA'); // false: one character off CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" def gstin_check_char(first14: str) -> str: s = 0 for i, ch in enumerate(first14): p = CHARS.index(ch) * (2 if i % 2 else 1) s += p // 36 + p % 36 return CHARS[(36 - s % 36) % 36] Run this in the form itself. It's free, it's instant, and it stops most bad input before it reaches your database.
3. Live lookup: is it real, and is it still active?
A number can pass the checksum and still be wrong for you: it may belong to someone else, or it may be cancelled or suspended. Claiming input tax credit on invoices from a cancelled GSTIN is the expensive version of this mistake. Only a lookup against GST registration data tells you the legal name, trade name and status.
Options:
- The GST portal search (services.gst.gov.in): fine for a one-off check by hand, has a captcha, not meant for automation.
- A GST Suvidha Provider (GSP) or a KYC/verification API: what most ERPs use.
- A pay-per-call GSTIN API. For example, with GSTIN.cloud (disclosure: this is the service I work on) it looks like this:
curl -H "X-API-Key: $GSTIN_CLOUD_KEY" \ https://gstin.cloud/api/v1/verify/22AAACL6442L1ZK { "success": true, "cached": true, "credits_remaining": 499, "data": { "gstin": "22AAACL6442L1ZK", "legal_name": "ULTRATECH CEMENT LIMITED", "status": "Active", "constitution": "Public Limited Company", "registration_date": "01/07/2017", "state": "Chhattisgarh", "pan": "AAACL6442L", "address": "...", "nature_of_business": ["Factory / Manufacturing", "Warehouse / Depot", "..."] } } Whichever provider you pick, compare on: price per call at your volume, whether results are cached (and how old a cached answer can be), rate limits, and whether you also get filing history (useful for vendor checks).
Putting it together
- Regex + checksum on input (client and server).
- Live lookup once, when the GSTIN is first saved; store the legal name and status.
- Re-check vendors periodically (monthly is common) and before large payments.
- Show the legal name back to the user: "Is this ULTRATECH CEMENT LIMITED?" catches the valid-but-wrong-business case that no checksum can.


