PAN

object PAN(source)

Validator, formatter, and masker for Indian Permanent Account Numbers (PAN).

PAN is a 10-character alphanumeric code issued by the Income Tax Department of India, uniquely identifying taxpayers — individuals, companies, HUFs, trusts, and other entities.

Format: [A-Z]{5}[0-9]{4}[A-Z]

  • Characters 1–3: alphabetic (freeform, assigned by ITD)

  • Character 4: entity category code — one of: P C H A B G J L F T

  • Character 5: first letter of the holder's name (individuals) or entity name

  • Characters 6–9: four-digit sequential number

  • Character 10: check letter (alphabetic; ITD has not published the algorithm)

4th-character entity category codes (index 3, 0-based):

  • P — Person / Individual

  • C — Company

  • H — Hindu Undivided Family (HUF)

  • A — Association of Persons (AOP)

  • B — Body of Individuals (BOI)

  • G — Government

  • J — Artificial Juridical Person

  • L — Local Authority

  • F — Firm / Limited Liability Partnership

  • T — Trust

PAN is financial PII (Income Tax ID). Mask before logging or displaying in UI. See mask for PII-safe display options.

Accepted input forms (all normalised before validation):

  • Raw uppercase: "ABCPE1234F"

  • Lowercase: "abcpe1234f" — normalised to uppercase

  • Mixed case: "AbCpE1234f" — normalised to uppercase

  • With spaces: "ABCPE 1234 F" — internal whitespace stripped

  • Whitespace padded: " ABCPE1234F " — leading/trailing whitespace trimmed

No checksum: The Income Tax Department has not published a public checksum algorithm for the 10th character. Validation is structural (format + category) only.

This object is stateless and thread-safe.

Samples

PAN.validate("ABCPE1234F") // ValidationResult.Valid
PAN.format("abcpe1234f") // "ABCPE1234F"
PAN.mask("ABCPE1234F") // "XXXXXX234F"

Functions

Link copied to clipboard
fun format(value: String): String

Formats a PAN to canonical form: 10-character uppercase, no separators.

Link copied to clipboard
fun isValid(value: String): Boolean

Returns true if validate returns ValidationResult.Valid.

Link copied to clipboard
fun mask(value: String, visibleStart: Int = 0, visibleEnd: Int = 4, maskChar: Char = 'X'): String

Masks a PAN for PII-safe display.

Link copied to clipboard

Validates an Indian Permanent Account Number (PAN).