India GSTIN Validator
Validate India Goods and Services Tax Identification Numbers (GSTIN). QA.
How GSTIN validation works
The validator checks if the input is exactly 15 characters and matches the official regex template. It verifies that the first two digits represent a valid state code, and parses the taxpayer's PAN.
It applies the alternating Modulo 36 algorithm across the first 14 characters with alternating weights [1, 2, 1, 2...] and checks if it matches the 15th digit.
Anatomy & Structure of the GSTIN (Goods and Services Tax Number)
The Indian GSTIN consists of 15 alphanumeric characters structured in 5 parts:
| Position | Field | Length | Meaning & Rule | Example |
|---|---|---|---|---|
| 1 & 2 | State Code | 2 digits | Official state/territory code (01 to 37 per Indian Census) | 27 |
| 3 to 12 | Entity PAN | 10 chars | Permanent Account Number of the entity (format AAAAA9999A) | AAPFU0939F |
| 13 | Entity Registration Count | 1 char | Number of registrations in the same state (1-9, A-Z) | 1 |
| 14 | Default Character | 1 char | Fixed character 'Z' by GSTN regulations | Z |
| 15 | Check Character | 1 char | Calculated via alternating Modulo 36 algorithm | 5 |
Official Algorithm (Alternating Modulo 36 — GSTN)
GSTIN uses alternating Modulo 36 with weights [1, 2, 1, 2...]:
factor = val * (pos%2 === 0 ? 1 : 2); sum += floor(factor/36) + (factor%36); Check = (36 - (sum%36))%36
- 1. Map each character to value 0-35 (0-9=0-9, A-Z=10-35).
- 2. Use weight 1 for even positions and weight 2 for odd positions.
- 3. Multiply character value by weight: factor = val × weight.
- 4. Add to sum: floor(factor / 36) + (factor % 36).
- 5. Take remainder modulo 36 and map to final check character.