Regex for GSTIN (GST number)
A GSTIN is a 15-character identifier used for GST registration in India. It combines a two-digit state code, the holder’s 10-character PAN, an entity number, the letter Z and a checksum character.
The pattern
/\b\d{2}[A-Z]{5}\d{4}[A-Z][1-9A-Z]Z[0-9A-Z]\b/gThe tester opens with this pattern and the examples below already loaded. Nothing you type is uploaded.
How it works
\d{2}- State or union territory code.
[A-Z]{5}\d{4}[A-Z]- The 10-character PAN of the registrant.
[1-9A-Z]- Entity number: how many registrations the same PAN holds in that state.
Z- The 14th character is the letter Z by default.
[0-9A-Z]- Final checksum character.
Examples
Matches
27AAPFU0939F1ZV07AABCU9603R1ZX29GGGGG1314R9Z6
Does not match
27AAPFU0939F1YV27AAPFU0939F0ZV27aapfu0939f1zv
Use it in JavaScript
const re = /\b\d{2}[A-Z]{5}\d{4}[A-Z][1-9A-Z]Z[0-9A-Z]\b/g;
// Find every match in a block of text
const found = text.match(re);
// Validate that a whole value matches (no stray characters around it)
const exact = new RegExp('^(?:' + re.source + ')$', re.flags.replace('g', ''));
const isValid = exact.test(value);Limits and tips
- This checks the structure only. It does not confirm the state code is valid, that the registration exists, or that the checksum character is correct.
- Look up registrations through the official GST portal or a GST verification API if you need to confirm a business is registered.
Frequently asked questions
How many characters does a GSTIN have?
Fifteen: 2 for the state, 10 for the PAN, 1 for the entity number, the letter Z, and 1 checksum character.
Does the GSTIN contain the PAN?
Yes. Characters 3 to 12 are the holder’s PAN, which is why the pattern reuses the PAN structure.