PatternRegex
Validate a GSTIN
Check a 15-character GSTIN's structure: state code, embedded PAN, entity number, the literal Z, and a checksum slot.
Last updated
Matches
- 29ABCDE1234F1Z5
- 22AAAAA0000A1Z5
Doesn’t match
- 29ABCDE1234F1Y5
- 9ABCDE1234F1Z5
- 29abcde1234f1z5
Why it’s written this way
A GSTIN packs several fields into 15 fixed positions: \d{2} for the state code, then [A-Z]{5}\d{4}[A-Z] — exactly the shape of a PAN number — embedded in the middle, followed by [1-9A-Z] for the entity number a business gets when it registers more than one GSTIN against the same PAN.
The literal Z is required at position 14 by the GST format spec; it isn't a placeholder character. The final [0-9A-Z] slot holds a checksum character that this pattern accepts the shape of but does not compute.
Edge cases to know
- →The trailing character is a checksum digit calculated from the other 14 — this pattern allows any letter or digit there, so a GSTIN with the wrong checksum still matches.
- →It doesn't verify that the embedded 10-character PAN portion is itself a real, issued PAN — that's a separate check against the same rules as the standalone PAN pattern.
- →State codes are two-digit numbers assigned by the GST Council — this pattern accepts any two digits, including ones not currently allocated to a state or union territory.